Add synterloper/uninstall_synterloper.sh
This commit is contained in:
parent
274902612c
commit
590210f069
1 changed files with 50 additions and 0 deletions
50
synterloper/uninstall_synterloper.sh
Normal file
50
synterloper/uninstall_synterloper.sh
Normal file
|
@ -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 ---"
|
Loading…
Add table
Add a link
Reference in a new issue