forked from aditya-shri/VPN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
53 lines (46 loc) · 1.75 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
46
47
48
49
50
51
52
53
#!/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"
V_VER=`wget -qO- "https://api.github.com/repos/shadowsocks/v2ray-plugin/releases/latest" | sed -n -r -e 's/.*"tag_name".+?"([vV0-9\.]+?)".*/\1/p'`
mkdir /wwwroot
mkdir /v2raybin
cd /v2raybin
V2RAY_URL="https://github.com/shadowsocks/v2ray-plugin/releases/download/${V_VER}/v2ray-plugin-linux-amd64-${V_VER}.tar.gz"
wget -q --no-check-certificate ${V2RAY_URL}
tar -zxvf v2ray-plugin-linux-amd64-$V_VER.tar.gz
rm -rf v2ray-plugin-linux-amd64-$V_VER.tar.gz
mv v2ray-plugin_linux_amd64 /usr/bin/v2ray-plugin
rm -rf /v2raybin
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;'