50 lines
1.3 KiB
Bash
50 lines
1.3 KiB
Bash
#!/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"
|
|
|
|
trap 'echo -e "\033[31mAn error has occurred\033[0m"; exit 1' ERR
|
|
set -e
|
|
|
|
rm "${DANTE_CONF}"
|
|
echo -e "\033[32mRemoved the danted.conf configuration file\033[0m"
|
|
|
|
echo "Rollback configuration file..."
|
|
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
|
|
|
|
echo "Remove the dante user..."
|
|
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
|
|
|
|
echo "Disable and stop the danted service..."
|
|
systemctl stop danted
|
|
systemctl disable danted
|
|
echo -e "\033[32mStopped and disabled the Dante service\033[0m"
|
|
|
|
echo "Uninstall dante-server package..."
|
|
apt-get -y remove dante-server
|
|
echo -e "\033[32mRemoved the dante-server package\033[0m"
|
|
|
|
trap - ERR
|
|
echo -e "\033[32mDante completely removed\033[0m" |