77 lines
2.0 KiB
Bash
77 lines
2.0 KiB
Bash
#!/bin/bash
|
|
|
|
# TODO: Add uninstall to readme
|
|
|
|
# Just double check, check /opt/vigil exists, then remove it, also check+remove systemd service, remove aliases from bashrc and also dont offer but notify that dependencies not uninstalled
|
|
|
|
# Check if vigil is installed, if not then exit
|
|
if [[ ! -d "/opt/vigil" ]]; then
|
|
echo "Vigil is not installed. Exiting." 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
# Check if we are running as root
|
|
if [[ $EUID -ne 0 ]]; then
|
|
echo "This script must be run as root" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
# Get the actual user (not root) for later use
|
|
ACTUAL_USER=${SUDO_USER:-$USER}
|
|
USER_HOME=$(eval echo ~$ACTUAL_USER)
|
|
|
|
# Now check if we are running on a supported system
|
|
if [[ "$OSTYPE" != "linux-gnu"* ]]; then
|
|
echo "This script is only supported on Linux" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
# Warning and countdown
|
|
echo "WARNING: This will remove /opt/vigil and any related data."
|
|
echo "Press Ctrl+C to cancel..."
|
|
echo ""
|
|
|
|
for i in 5 4 3 2 1; do
|
|
echo -n "$i..."
|
|
sleep 1
|
|
done
|
|
echo ""
|
|
echo ""
|
|
|
|
# Final confirmation
|
|
echo "Continue with uninstallation? (y/n)"
|
|
read -r answer
|
|
if [[ "${answer,,}" != "y" ]]; then
|
|
echo "Uninstallation cancelled."
|
|
exit 0
|
|
fi
|
|
|
|
# Now delete the vigil directory
|
|
echo ""
|
|
echo "Removing Vigil installation..."
|
|
rm -rf /opt/vigil
|
|
|
|
# Now delete the systemd service (if it exists)
|
|
if [[ -f /etc/systemd/system/vigil.service ]]; then
|
|
echo "Removing Vigil systemd service..."
|
|
systemctl stop vigil.service 2>/dev/null
|
|
systemctl disable vigil.service 2>/dev/null
|
|
rm /etc/systemd/system/vigil.service
|
|
systemctl daemon-reload
|
|
else
|
|
echo "No systemd service found (skipping)"
|
|
fi
|
|
|
|
# Now delete the aliases from bashrc
|
|
echo "Removing Vigil aliases from bashrc..."
|
|
if grep -q "alias vigil=" "$USER_HOME/.bashrc" 2>/dev/null; then
|
|
sed -i '/alias vigil=/d' "$USER_HOME/.bashrc"
|
|
echo "Aliases removed from $USER_HOME/.bashrc"
|
|
else
|
|
echo "No aliases found in bashrc"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Dependencies not uninstalled. Please uninstall them manually if needed: python3, git, pip"
|
|
echo "Vigil has been uninstalled successfully."
|