install.sh: add SUCCESS log as well

This commit is contained in:
krolxon 2026-01-01 22:13:35 +05:30
parent 884fda0886
commit 24ee83b90f
1 changed files with 11 additions and 9 deletions

View File

@ -4,15 +4,17 @@ log() {
local level="$1" local level="$1"
shift shift
local color reset='\033[0m'
case "$level" in case "$level" in
INFO) color='\033[0;32m' ;; INFO) color='\033[0;34m' ;; # Blue
WARN) color='\033[0;33m' ;; WARN) color='\033[0;33m' ;; # Yellow
ERROR) color='\033[0;31m' ;; ERROR) color='\033[0;31m' ;; # Red
*) color='\033[0m' ;; SUCCESS) color='\033[0;32m' ;; # Green
*) color='\033[0m' ;;
esac esac
printf '%b[%s] [%s]%b %s\n' \ printf '%b[%s] [%s]%b %s\n' \
"$color" "$(date '+%H:%M:%S')" "$level" '\033[0m' "$*" "$color" "$(date '+%H:%M:%S')" "$level" "$reset" "$*" >&2
} }
# Prevent user from running this script as root # Prevent user from running this script as root
@ -89,7 +91,7 @@ if [[ "$confirm" =~ ^[Yy]$ ]]; then
if [[ -z "$conflicts" ]]; then if [[ -z "$conflicts" ]]; then
log INFO "No conflicts. Running stow normally..." log INFO "No conflicts. Running stow normally..."
stow . --no-folding \ stow . --no-folding \
&& log INFO "Dotfiles stowed successfully" \ && log SUCCESS "Dotfiles stowed successfully" \
|| log ERROR "Stow failed" || log ERROR "Stow failed"
else else
log WARN "These paths conflict and will be removed:" log WARN "These paths conflict and will be removed:"
@ -131,7 +133,7 @@ if [[ "$SHELL" != "$(which zsh)" ]]; then
read -rp "Change default shell to ZSH? (y/N): " confirm read -rp "Change default shell to ZSH? (y/N): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then if [[ "$confirm" =~ ^[Yy]$ ]]; then
chsh -s $(which zsh) \ chsh -s $(which zsh) \
&& log INFO "Default shell successfully set to zsh" \ && log SUCCESS "Default shell successfully set to zsh" \
|| log ERROR "Default shell could not be set to zsh" || log ERROR "Default shell could not be set to zsh"
fi fi
else else
@ -145,7 +147,7 @@ if [[ "$confirm" =~ ^[Yy]$ ]]; then
log INFO "Copying keyd configuration to /etc/keyd/default.conf" log INFO "Copying keyd configuration to /etc/keyd/default.conf"
sudo cp "$currentDir/system/etc/keyd/default.conf" /etc/keyd/ sudo cp "$currentDir/system/etc/keyd/default.conf" /etc/keyd/
sudo systemctl enable --now keyd.service \ sudo systemctl enable --now keyd.service \
&& log INFO "Successfully enabled keyd.service" \ && log SUCCESS "Successfully enabled keyd.service" \
|| log ERROR "Couldn't enable keyd.service" || log ERROR "Couldn't enable keyd.service"
fi fi
@ -153,4 +155,4 @@ fi
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
echo "" echo ""
log INFO "Done!" log SUCCESS "Done!"