-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_setup.sh
executable file
·76 lines (65 loc) · 1.8 KB
/
server_setup.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
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ]
then
echo "Supply username and livepatch token"
exit 1
fi
#upgrade os
apt update && apt dist-upgrade -y
#basic packages
#apt autoremove --purge snapd
apt install -y fonts-powerline \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common \
fish \
cifs-utils \
nfs-common \
net-tools \
iperf \
git \
build-essential \
gnupg \
lsb-release \
unattended-upgrades
#livepatch
snap install canonical-livepatch
ua attach $2
ua enable livepatch
#unattended-upgrades
nano /etc/apt/apt.conf.d/50unattended-upgrades
#swappiness
swapoff -a
rm /swap.img
fallocate -l 8G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
sysctl vm.swappiness=10
echo "vm.swappiness=10" >> /etc/sysctl.conf
#ufw
ufw allow openssh
ufw enable
# Add specified user
adduser $1
#docker
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
usermod -aG docker $1
#fish
chsh -s `which fish`
sudo -u $1 chsh -s `which fish`
fish -c "curl -L https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish"
fish -c "omf install bobthefish"
sudo -u $1 fish -c "curl -L https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish"
sudo -u $1 fish -c "omf install bobthefish"
sudo chown -R $1:$1 /home/$1/.config/
exit 0