apt-get, echo msgs
This commit is contained in:
parent
6c7681fe57
commit
0ae6ef74c9
@ -8,30 +8,28 @@ else
|
||||
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"
|
||||
|
||||
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"
|
||||
|
||||
# Rollback configuration file
|
||||
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
|
||||
|
||||
# Remove the dante user
|
||||
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"
|
||||
@ -39,13 +37,13 @@ else
|
||||
echo -e "\033[33mDante user does not exist. Skipping user removal\033[0m"
|
||||
fi
|
||||
|
||||
# Disable and stop the danted service
|
||||
echo "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 "Uninstall dante-server package..."
|
||||
apt-get -y remove dante-server
|
||||
echo -e "\033[32mRemoved the dante-server package\033[0m"
|
||||
|
||||
trap - ERR
|
||||
|
||||
22
socks5.sh
22
socks5.sh
@ -10,15 +10,16 @@ if [ -z "$1" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DANTE_CONF="/etc/danted.conf"
|
||||
DANTE_USER="usrsocks"
|
||||
DANTE_PASSWORD=$1
|
||||
|
||||
trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' ERR
|
||||
set -e
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
DANTE_CONF="/etc/danted.conf"
|
||||
DANTE_USER="usrsocks"
|
||||
DANTE_PASSWORD=$1
|
||||
|
||||
echo "Find active network interface..."
|
||||
INTERFACE=$(ip -o -4 route show to default | awk '{print $5}')
|
||||
|
||||
if [ -z "$INTERFACE" ]; then
|
||||
@ -28,11 +29,11 @@ fi
|
||||
|
||||
echo "Active network interface found: $INTERFACE"
|
||||
|
||||
apt update
|
||||
apt install -y dante-server
|
||||
echo "Install dante-server..."
|
||||
apt-get update
|
||||
apt-get install -y dante-server
|
||||
|
||||
|
||||
# Backup existing configuration file
|
||||
echo "Backup existing configuration file $DANTE_CONF..."
|
||||
if [ -f "${DANTE_CONF}" ]; then
|
||||
cp "$DANTE_CONF" "${DANTE_CONF}.bak"
|
||||
echo -e "\033[32mBackup existing configuration file\033[0m"
|
||||
@ -73,13 +74,14 @@ NEW_CONFIG=$(cat <<-EOM
|
||||
EOM
|
||||
)
|
||||
|
||||
# Write configuration file
|
||||
echo "Write configuration file $DANTE_CONF..."
|
||||
echo "$NEW_CONFIG" > "$DANTE_CONF"
|
||||
|
||||
# Create user for auth
|
||||
echo "Create user $DANTE_USER for SOCKS5 auth..."
|
||||
useradd -s /bin/false $DANTE_USER
|
||||
echo "$DANTE_USER:$DANTE_PASSWORD" | chpasswd
|
||||
|
||||
echo "restart danted service..."
|
||||
systemctl restart danted
|
||||
systemctl enable danted
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user