diff --git a/synterloper/uninstall_synterloper.sh b/synterloper/uninstall_synterloper.sh new file mode 100644 index 0000000..a02883d --- /dev/null +++ b/synterloper/uninstall_synterloper.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# +# uninstall_synterloper.sh +# +# This script stops the SYNterloper service and removes all its components. +# + +LOG_DIR="/var/log/synterloper" + +if [ "$(id -u)" -ne 0 ]; then + echo "Error: This script must be run as root." >&2 + exit 1 +fi + +echo "This script will stop the SYNterloper service and remove:" +echo " - The systemd/rc.d service file" +echo " - The daily cleanup cron job" +echo " - The log directory: ${LOG_DIR}" +printf "Proceed with uninstallation? (y/N) " +read -r confirmation +if [ "$confirmation" != "y" ] && [ "$confirmation" != "Y" ]; then + echo "Uninstallation aborted." + exit 0 +fi + +OS_TYPE=$(uname) +echo "Detected OS: ${OS_TYPE}" + +if [ "${OS_TYPE}" = "Linux" ]; then + echo "Stopping and disabling systemd service..." + systemctl stop synterloper.service + systemctl disable synterloper.service + rm -f /etc/systemd/system/synterloper.service + systemctl daemon-reload +elif [ "${OS_TYPE}" = "FreeBSD" ]; then + echo "Stopping and disabling rc.d service..." + service synterloper stop + sysrc -x synterloper_enable synterloper_port synterloper_logdir synterloper_rotate_sec synterloper_snaplen + rm -f /usr/local/etc/rc.d/synterloper +fi +echo "Service has been removed." + +echo "Removing cleanup cron job..." +rm -f /etc/cron.daily/synterloper-cleanup + +echo "Removing log directory..." +rm -rf "${LOG_DIR}" + +echo "" +echo "--- Uninstallation Complete ---" \ No newline at end of file