82 lines
1.5 KiB
Bash
Executable File
82 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
install_package()
|
|
{
|
|
if [ "$#" -eq 0 ]; then
|
|
gum style --foreground 9 "✗ no package provided!"
|
|
return 1
|
|
fi
|
|
|
|
local package="$1"
|
|
|
|
if gum spin --title="Installing $package..." --show-error -- sudo xbps-install -Sy "$package"; then
|
|
gum style --foreground 10 "✓ $package"
|
|
else
|
|
gum style --foreground 9 "✗ $package"
|
|
fi
|
|
}
|
|
|
|
install_service()
|
|
{
|
|
if [ "$#" -eq 0 ]; then
|
|
echo echo "ERROR: No service provided!"
|
|
return 1
|
|
fi
|
|
|
|
local service="$1"
|
|
|
|
if [ -e "/var/service/$service" ]; then
|
|
sudo rm -rf "/var/service/$service"
|
|
fi
|
|
|
|
if sudo ln -s "/etc/sv/$service" "/var/service/"; then
|
|
gum style --foreground 10 "✓ $service"
|
|
else
|
|
gum style --foreground 9 "✗ $service"
|
|
fi
|
|
}
|
|
|
|
remove_service()
|
|
{
|
|
if [ "$#" -eq 0 ]; then
|
|
echo echo "ERROR: No service provided!"
|
|
return 1
|
|
fi
|
|
|
|
local service="$1"
|
|
|
|
if sudo rm "/var/service/$service"; then
|
|
gum style --foreground 10 "✓ $service"
|
|
else
|
|
gum style --foreground 9 "✗ $service"
|
|
fi
|
|
}
|
|
|
|
install_dotfiles()
|
|
{
|
|
if [ $# -ne 3 ]; then
|
|
gum style --foreground 9 "✗ expected 3 arguments - target, dir, name"
|
|
return 1
|
|
fi
|
|
|
|
target="$1"
|
|
dir="$2"
|
|
name="$3"
|
|
|
|
if [ ! -e "$target" ]; then
|
|
gum style --foreground 9 "✗ target path is invelid"
|
|
return 1
|
|
fi
|
|
|
|
if [ ! -e "$dir" ]; then
|
|
gum style --foreground 9 "✗ dir path is invelid"
|
|
return 1
|
|
fi
|
|
|
|
if sudo stow -R --target="$target" --dir="$dir" "$name"; then
|
|
gum style --foreground 10 "✓ $name"
|
|
else
|
|
gum style --foreground 9 "✗ $name"
|
|
fi
|
|
}
|