#!/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 # Ensure the script runs with superuser rights if [ "$(id -u)" != "0" ]; then echo -e "\033[31mThis script requires superuser rights.\033[0m" exit 1 fi # Trap errors and exit trap 'echo -e "\033[31mAn error has occurred\033[0m"; exit 1' ERR set -e DANTE_CONF="/etc/danted.conf" DANTE_USER="usrsocks" rm "${DANTE_CONF}" echo -e "\033[32mRemoved the danted.conf configuration file\033[0m" # 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 # 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 # Disable and stop the danted service systemctl stop danted systemctl disable danted echo -e "\033[32mStopped and disabled the Dante service\033[0m" # Uninstall dante-server package apt -y remove dante-server echo -e "\033[32mRemoved the dante-server package\033[0m" trap - ERR echo -e "\033[32mDante completely removed\033[0m"