-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcloud-init.yml
More file actions
43 lines (42 loc) · 1.6 KB
/
cloud-init.yml
File metadata and controls
43 lines (42 loc) · 1.6 KB
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
#cloud-config
package_update: true
packages:
- docker.io
- docker-compose
- certbot
runcmd:
- systemctl enable docker
- systemctl start docker
- |
while ! docker info >/dev/null 2>&1; do
echo "Docker not ready yet... retrying in 15s"
sleep 15
done
if [ "{{MODE}}" = "tls" ]; then
echo "Starting Shadowsocks server with TLS..."
certbot certonly --standalone --non-interactive --agree-tos \
-m {{EMAIL}} \
-d {{FQDN}}
docker run -d --name shadowsocks --restart unless-stopped \
-p 443:443 \
-v /etc/letsencrypt:/etc/letsencrypt:ro \
teddysun/shadowsocks-rust:latest \
ssserver -s 0.0.0.0:443 \
-m chacha20-ietf-poly1305 \
-k "{{PASSWORD}}" \
--plugin v2ray-plugin \
--plugin-opts "server;tls;host={{FQDN}};cert=/etc/letsencrypt/live/{{FQDN}}/fullchain.pem;key=/etc/letsencrypt/live/{{FQDN}}/privkey.pem"
mkdir -p /etc/letsencrypt/renewal-hooks/deploy
echo '#!/bin/bash' > /etc/letsencrypt/renewal-hooks/deploy/restart-shadowsocks.sh
echo 'docker restart shadowsocks' >> /etc/letsencrypt/renewal-hooks/deploy/restart-shadowsocks.sh
chmod +x /etc/letsencrypt/renewal-hooks/deploy/restart-shadowsocks.sh
else
echo "Starting Shadowsocks server with tcp-udp..."
docker run -d --name shadowsocks --restart unless-stopped \
-p 443:443/tcp \
-p 443:443/udp \
teddysun/shadowsocks-rust:latest \
ssserver -s 0.0.0.0:443 \
-m chacha20-ietf-poly1305 \
-k "{{PASSWORD}}"
fi