socks5/socks5-uninstall.sh

50 lines
1.3 KiB
Bash
Raw Normal View History

2024-07-27 04:26:48 +05:00
#!/bin/bash
read -p "Dante will be completely removed. Do you want to continue? (y/n): " answer
if [ "$answer" != "${answer#[Yy]}" ]; then
echo "Deleting..."
else
echo "Canceled by user"
exit 1
fi
if [ "$(id -u)" != "0" ]; then
echo -e "\033[31mThis script requires superuser rights.\033[0m"
exit 1
fi
DANTE_CONF="/etc/danted.conf"
DANTE_USER="usrsocks"
2024-08-05 07:24:59 +05:00
trap 'echo -e "\033[31mAn error has occurred\033[0m"; exit 1' ERR
set -e
2024-07-27 04:26:48 +05:00
rm "${DANTE_CONF}"
echo -e "\033[32mRemoved the danted.conf configuration file\033[0m"
2024-08-05 07:24:59 +05:00
echo "Rollback configuration file..."
2024-07-27 04:26:48 +05:00
if [ -f "${DANTE_CONF}.bak" ]; then
# If backup exists, remove it
rm "${DANTE_CONF}.bak"
echo -e "\033[32mRemoved the danted.conf.bak file\033[0m"
fi
2024-08-05 07:24:59 +05:00
echo "Remove the dante user..."
2024-07-27 04:26:48 +05:00
if id "$DANTE_USER" &>/dev/null; then
userdel -r "$DANTE_USER"
echo -e "\033[32mRemoved the dante user and its home directory\033[0m"
else
echo -e "\033[33mDante user does not exist. Skipping user removal\033[0m"
fi
2024-08-05 07:24:59 +05:00
echo "Disable and stop the danted service..."
2024-07-27 04:26:48 +05:00
systemctl stop danted
systemctl disable danted
echo -e "\033[32mStopped and disabled the Dante service\033[0m"
2024-08-05 07:24:59 +05:00
echo "Uninstall dante-server package..."
apt-get -y remove dante-server
2024-07-27 04:26:48 +05:00
echo -e "\033[32mRemoved the dante-server package\033[0m"
trap - ERR
echo -e "\033[32mDante completely removed\033[0m"