-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
45 lines (38 loc) · 1.27 KB
/
entrypoint.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
#!/bin/bash
if [[ -z "${Password}" ]]; then
Password="5c301bb8-6c77-41a0-a606-4ba11bbab084"
fi
ENCRYPT="chacha20-ietf-poly1305"
QR_Path="/qr"
#V2Ray Configuration
V2_Path="/v2"
mkdir /wwwroot
mv /v2 /usr/bin/v2
if [ ! -d /etc/shadowsocks-libev ]; then
mkdir /etc/shadowsocks-libev
fi
# TODO: bug when PASSWORD contain '/'
sed -e "/^#/d"\
-e "s/\${PASSWORD}/${Password}/g"\
-e "s/\${ENCRYPT}/${ENCRYPT}/g"\
-e "s|\${V2_Path}|${V2_Path}|g"\
/conf/shadowsocks-libev_config.json > /etc/shadowsocks-libev/config.json
echo /etc/shadowsocks-libev/config.json
cat /etc/shadowsocks-libev/config.json
sed -e "/^#/d"\
-e "s/\${PORT}/${PORT}/g"\
-e "s|\${V2_Path}|${V2_Path}|g"\
-e "s|\${QR_Path}|${QR_Path}|g"\
-e "$s"\
/conf/nginx_ss.conf > /etc/nginx/conf.d/ss.conf
if [ "${Domain}" = "no" ]; then
echo "Aditya's Personal VPN"
else
plugin=$(echo -n "v2ray;path=${V2_Path};host=${Domain};tls" | sed -e 's/\//%2F/g' -e 's/=/%3D/g' -e 's/;/%3B/g')
ss="ss://$(echo -n ${ENCRYPT}:${Password} | base64 -w 0)@${Domain}:443?plugin=${plugin}"
echo "${ss}" | tr -d '\n' > /wwwroot/index.html
echo -n "${ss}" | qrencode -s 6 -o /wwwroot/vpn.png
fi
ss-server -c /etc/shadowsocks-libev/config.json &
rm -rf /etc/nginx/sites-enabled/default
nginx -g 'daemon off;'