#!/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 # Prepare app environment: apt-get update -y apt-get upgrade -y apt-get install -y mc vim pwgen # ... zip # Set timezone: timedatectl set-timezone Asia/Yekaterinburg echo "Timezone changed:" timedatectl # add new sudo user: 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 echo "Init complete"