add basic first time installation

This commit is contained in:
desolate
2026-05-14 18:21:18 +03:00
commit 7cb75b72c8
72 changed files with 1198 additions and 0 deletions
Executable
+107
View File
@@ -0,0 +1,107 @@
#!/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
if [ ! -f "/etc/sv/$service/down" ]; then
sudo touch "/etc/sv/$service/down"
fi
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
}
run_service()
{
if [ "$#" -eq 0 ]; then
echo echo "✗ no service provided!"
return 1
fi
local service="$1"
if [ -f "/etc/sv/$service/down" ]; then
sudo rm "/etc/sv/$service/down"
fi
if sudo sv up "$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
}