-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap-server.sh
executable file
·81 lines (55 loc) · 1.56 KB
/
bootstrap-server.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bash
user="michael"
if ! id -u "$user"; then
adduser "$user"
adduser "$user" sudo
read -r -p "Do you want to add www user? [y/N]" yn
if [ "$yn" = "Y" ] || [ "$yn" = "y" ]; then
adduser www
mkdir /var/www
chown www:www /var/www
echo "Added www user."
fi
echo "Created user.
1. exit
2. ssh-copy-id -i ~/.ssh/key $user@[ip]
3. ssh-copy-id -i ~/.ssh/wwwkey www@[ip]
3. ssh $user@[ip]
4. Run this file again
"
exit 0
fi
echo "Cloning dotfiles...."
mkdir ~/docs
cd ~/docs || exit
git clone https://github.com/sarmong/dotfiles.git
cd dotfiles || exit
echo "Updating sudo to use vim by default"
echo "Defaults editor=/usr/bin/vim, !env_editor" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/editor')
echo "Updating sshd_config with the following values:"
echo "
PermitRootLogin no
PasswordAuthentication no
X11Forwarding no" | sudo tee -a /etc/ssh/sshd_config
sudo systemctl reload sshd
echo "Installing packages: "
sed 's/#.*$//g' ./server/debian.txt | sed '/^$/d' | xargs sudo apt install -y
## Firewall
echo "Enabling firewall..."
sudo ufw allow 'OpenSSH'
sudo ufw allow 'Nginx Full'
sudo ufw allow 80,443/tcp
sudo ufw enable
echo "Linking files..."
./link.sh
echo "Changing shell to zsh..."
chsh -s /usr/bin/zsh
echo "Adding user to docker group..."
if command docker >/dev/null 2>&1; then
sudo usermod -aG docker "$USER"
if id www >/dev/null 2>&1; then
sudo usermod -aG docker www
fi
fi
newgrp docker # applies the changes to the group
echo "Open another terminal window and check if you can login"