sshtunnel/bin/scripts/uninstall.sh
2025-05-23 15:08:44 +02:00

37 lines
1.2 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/sshtunnel ] || [ -f /usr/share/bash-completion/completions/sshtunnel ] || [ -f /usr/local/share/sshtunnel/sshtunnel.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 sshtunnel from user-local locations..."
if [ -f $HOME/.local/bin/sshtunnel ]; then
log_and_run rm $HOME/.local/bin/sshtunnel
fi
if [ -f $HOME/.local/bin/sshtunnel-completion.bash ]; then
log_and_run rm $HOME/.local/bin/sshtunnel-completion.bash
fi
# Remove system-wide files using log_and_run
printfe "%s\n" "cyan" "Removing sshtunnel from system-wide locations..."
if [ -f /usr/share/bash-completion/completions/sshtunnel ]; then
log_and_run rm /usr/share/bash-completion/completions/sshtunnel
fi
if [ -f /usr/local/bin/sshtunnel ]; then
log_and_run rm /usr/local/bin/sshtunnel
fi
if [ -f /usr/local/share/sshtunnel/sshtunnel.version ]; then
log_and_run rm /usr/local/share/sshtunnel/sshtunnel.version
fi
printfe "%s\n" "green" "Uninstall complete."