utils/init-server.sh

44 lines
811 B
Bash
Raw Normal View History

2024-07-30 06:31:58 +05:00
#!/bin/bash
USERNAME=usradmin
SSH_PORT=2525
if [ "$(id -u)" != "0" ]; then
echo -e "\033[31mThis script requires superuser rights.\033[0m"
exit 0
fi
trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' ERR
set -e
export DEBIAN_FRONTEND=noninteractive
apt update -y
apt upgrade -y
apt install -y mc vim zip pwgen
timedatectl set-timezone Asia/Yekaterinburg
echo "Timezone changed:"
timedatectl
if id "$USERNAME" &>/dev/null; then
echo "User $USERNAME already exists"
else
useradd -m -s /bin/bash "$USERNAME"
usermod -aG sudo "$USERNAME"
fi
chown "$USERNAME":"$USERNAME" /data
chmod 770 /data
mkdir -p /backups
chown "$USERNAME":"$USERNAME" /backups
chmod 770 /backups
# SSH config:
cd /data/utils
bash ssh-port.sh $SSH_PORT
#bash ssh-pw.sh n
trap - ERR
2024-07-27 04:15:43 +05:00
echo "Init complete"