utils/init-server.sh

48 lines
893 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
2024-08-05 04:22:16 +05:00
# Prepare app environment:
2024-08-05 05:18:37 +05:00
apt-get update -y
apt-get upgrade -y
apt-get install -y mc vim pwgen
2024-08-05 04:22:16 +05:00
# ... zip
2024-07-30 06:31:58 +05:00
2024-08-05 04:22:16 +05:00
# Set timezone:
2024-07-30 06:31:58 +05:00
timedatectl set-timezone Asia/Yekaterinburg
echo "Timezone changed:"
timedatectl
2024-08-05 04:22:16 +05:00
# add new sudo user:
2024-07-30 06:31:58 +05:00
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"