forked from pockethost/pockethost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
67 lines (52 loc) · 1.96 KB
/
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
#!/bin/bash
# Update the package list and upgrade all packages
apt-get update -y
apt-get upgrade -y
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do apt-get remove $pkg; done
# Add Docker's official GPG key:
apt-get update
apt-get install ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
certbot certonly \
--dns-cloudflare \
--dns-cloudflare-credentials ~/certbot-creds.ini \
-d *.sfo-2.pockethost.io \
--agree-tos \
--no-eff-email \
--email [email protected]
# Create user pockethost with no password
adduser --disabled-password --gecos "" pockethost
# Grant passwordless sudo privileges to pockethost
echo "pockethost ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/pockethost
# Update configurations
ufw allow OpenSSH
ufw allow https
ufw allow http
ufw allow ftp
echo "y" | ufw enable
# Copy root's authorized_keys to pockethost
mkdir -p /home/pockethost/.ssh
cp /root/.ssh/authorized_keys /home/pockethost/.ssh/authorized_keys
chown -R pockethost:pockethost /home/pockethost/.ssh
chmod 700 /home/pockethost/.ssh
chmod 600 /home/pockethost/.ssh/authorized_keys
# Add GitHub to known hosts to prevent interactive prompt
su - pockethost -c "ssh-keyscan github.com >> ~/.ssh/known_hosts"
#####
# As pockethost user
#####
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
git clone [email protected]:pockethost/pockethost.git
cd pockethost
nvm install
npm i -g pnpm pm2
pnpm i