#!/bin/bash # Check if running as root if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" 1>&2 exit 1 fi echo "This will uninstall Vigil from your system." echo "" echo "What would you like to remove?" echo " 1) Everything (code, config, and logs)" echo " 2) Just the code (preserve /etc/vigil and /var/log/vigil)" echo " 3) Cancel" echo "" read -p "Enter choice [1-3]: " choice case $choice in 1) REMOVE_ALL=true ;; 2) REMOVE_ALL=false ;; 3) echo "Uninstall cancelled." exit 0 ;; *) echo "Invalid choice. Uninstall cancelled." exit 1 ;; esac # Stop and disable service echo "" echo "Stopping vigil service..." systemctl stop vigil 2>/dev/null systemctl disable vigil 2>/dev/null # Remove systemd service echo "Removing systemd service..." rm -f /etc/systemd/system/vigil.service systemctl daemon-reload # Remove command echo "Removing vigil command..." rm -f /usr/local/bin/vigil # Remove code echo "Removing code from /opt/vigil..." rm -rf /opt/vigil if [[ "$REMOVE_ALL" == "true" ]]; then echo "Removing configuration from /etc/vigil..." rm -rf /etc/vigil echo "Removing logs from /var/log/vigil..." rm -rf /var/log/vigil echo "" echo "✓ Vigil completely removed from your system" else echo "" echo "✓ Vigil code removed" echo "✓ Configuration preserved in /etc/vigil" echo "✓ Logs preserved in /var/log/vigil" echo "" echo "To reinstall: curl ... | sudo bash" fi echo ""