-
Notifications
You must be signed in to change notification settings - Fork 1
/
instance-startup.bash
executable file
·61 lines (48 loc) · 1.44 KB
/
instance-startup.bash
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
#!/usr/bin/env bash
set -x
set -euo pipefail
IFS=$'\n\t'
ufw allow ssh
ufw enable
ua status --wait
ua refresh
canonical-livepatch refresh
snap refresh
snap install docker
snap start docker
apt update
apt -y full-upgrade
apt -y install unattended-upgrades wireguard-tools
tee /etc/apt/apt.conf.d/20auto-upgrades << 'EOF'
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";
EOF
tee /etc/apt/apt.conf.d/50unattended-upgrades << 'EOF'
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
"${distro_id}:${distro_codename}-updates";
};
Unattended-Upgrade::Package-Blacklist {
};
EOF
tee /etc/apt/apt.conf.d/60unattended-reboot << 'EOF'
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "03:30";
EOF
pushd /var/local
curl -sSO https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.sh
bash add-google-cloud-ops-agent-repo.sh --also-install
popd
mkdir -p /root/easy-wg-quick
pushd /root/easy-wg-quick
echo ufw > fwtype.txt
echo 443 > portno.txt
ip route sh | awk '$1 == "default" && $2 == "via" { print $5; exit }' > extnetif.txt
curl -4 ifconfig.co/ip > extnetip.txt
docker run --rm -v "${PWD}:/pwd" ghcr.io/burghardt/easy-wg-quick
cp wghub.conf /etc/wireguard/wghub.conf
popd
systemctl enable wg-quick@wghub
systemctl start wg-quick@wghub