kcm/bin/scripts/uninstall.sh

37 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
source bin/helpers/func.sh
# Test for root privileges if uninstalling system-wide files
NEED_ROOT=0
if [ -f /usr/local/bin/kcm ] || [ -f /usr/share/bash-completion/completions/kcm ] || [ -f /usr/local/share/kcm/kcm.version ]; then
NEED_ROOT=1
fi
if [ $NEED_ROOT -eq 1 ] && [ "$EUID" -ne 0 ]; then
printfe "%s\n" "red" "Please run as root"
exit 1
fi
# Remove user-local files
printfe "%s\n" "cyan" "Removing kcm from user-local locations..."
if [ -f $HOME/.local/bin/kcm ]; then
log_and_run rm $HOME/.local/bin/kcm
fi
if [ -f $HOME/.local/bin/kcm-completion.bash ]; then
log_and_run rm $HOME/.local/bin/kcm-completion.bash
fi
# Remove system-wide files using log_and_run
printfe "%s\n" "cyan" "Removing kcm from system-wide locations..."
if [ -f /usr/share/bash-completion/completions/kcm ]; then
log_and_run rm /usr/share/bash-completion/completions/kcm
fi
if [ -f /usr/local/bin/kcm ]; then
log_and_run rm /usr/local/bin/kcm
fi
if [ -f /usr/local/share/kcm/kcm.version ]; then
log_and_run rm /usr/local/share/kcm/kcm.version
fi
printfe "%s\n" "green" "Uninstall complete."