Skip to content

Instantly share code, notes, and snippets.

@udovichenko
Last active September 18, 2022 17:50
Show Gist options
  • Save udovichenko/3011572c5a9b1a8d92b3eaa19e7ff97d to your computer and use it in GitHub Desktop.
Save udovichenko/3011572c5a9b1a8d92b3eaa19e7ff97d to your computer and use it in GitHub Desktop.
Server with Docker setup
USERNAME=
DOMAIN=
#!/bin/bash
# curl -fsSL https://gist.githubusercontent.com/udovichenko/3011572c5a9b1a8d92b3eaa19e7ff97d/raw/setup.sh -o setup.sh
USERNAME=$1
if [ -z "$USERNAME" ]; then
echo "Please specify username as the argument"
exit
fi
echo "You chose username: $USERNAME"
cd "${HOME}" || exit
sed -i "s/.*SystemMaxUse.*/SystemMaxUse=100M/g" /etc/systemd/journald.conf
curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-compose make micro s3cmd tree
wget https://gist.githubusercontent.com/udovichenko/cf82c93e193d18d51166e3299aba1c24/raw/.bash_aliases
PASS=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c24)
echo "$PASS" >> ./pass.txt
useradd "$USERNAME" -m -s "/bin/bash" -d "/home/$USERNAME"
echo "$USERNAME:$PASS" | chpasswd
adduser "$USERNAME" docker
mkdir -p "/home/${USERNAME}/.ssh"
cp /root/.ssh/authorized_keys "/home/${USERNAME}/.ssh/"
cp /root/.ssh/authorized_keys "/home/${USERNAME}/.ssh/"
chown "${USERNAME}:${USERNAME}" "/home/${USERNAME}/.ssh" "/home/${USERNAME}/.ssh/"*
sudo -iu "$USERNAME" docker network create nginx-proxy
cd "/home/${USERNAME}" || exit
sudo -iu "$USERNAME" wget https://gist.githubusercontent.com/udovichenko/cf82c93e193d18d51166e3299aba1c24/raw/.bash_aliases
sudo -iu "$USERNAME" mkdir apps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment