-
Notifications
You must be signed in to change notification settings - Fork 174
/
entrypoint.sh
executable file
·94 lines (77 loc) · 2.44 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
#v2ray-plugin版本
if [[ -z "${VER}" ]]; then
VER="latest"
fi
echo ${VER}
if [[ -z "${PASSWORD}" ]]; then
PASSWORD="5c301bb8-6c77-41a0-a606-4ba11bbab084"
fi
echo ${PASSWORD}
if [[ -z "${ENCRYPT}" ]]; then
ENCRYPT="rc4-md5"
fi
if [[ -z "${V2_Path}" ]]; then
V2_Path="/s233"
fi
echo ${V2_Path}
if [[ -z "${QR_Path}" ]]; then
QR_Path="/qr_img"
fi
echo ${QR_Path}
if [ "$VER" = "latest" ]; then
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'`
[[ -z "${V_VER}" ]] && V_VER="v1.3.0"
else
V_VER="v$VER"
fi
mkdir /v2raybin
cd /v2raybin
V2RAY_URL="https://github.com/shadowsocks/v2ray-plugin/releases/download/${V_VER}/v2ray-plugin-linux-amd64-${V_VER}.tar.gz"
echo ${V2RAY_URL}
wget --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
cd /wwwroot
tar xvf wwwroot.tar.gz
rm -rf wwwroot.tar.gz
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
if [[ -z "${ProxySite}" ]]; then
s="s/proxy_pass/#proxy_pass/g"
echo "site:use local wwwroot html"
else
s="s|\${ProxySite}|${ProxySite}|g"
echo "site: ${ProxySite}"
fi
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
echo /etc/nginx/conf.d/ss.conf
cat /etc/nginx/conf.d/ss.conf
if [ "$AppName" = "no" ]; then
echo "不生成二维码"
else
[ ! -d /wwwroot/${QR_Path} ] && mkdir /wwwroot/${QR_Path}
plugin=$(echo -n "v2ray;path=${V2_Path};host=${AppName}.herokuapp.com;tls" | sed -e 's/\//%2F/g' -e 's/=/%3D/g' -e 's/;/%3B/g')
ss="ss://$(echo -n ${ENCRYPT}:${PASSWORD} | base64 -w 0)@${AppName}.herokuapp.com:443?plugin=${plugin}"
echo "${ss}" | tr -d '\n' > /wwwroot/${QR_Path}/index.html
echo -n "${ss}" | qrencode -s 6 -o /wwwroot/${QR_Path}/v2.png
fi
ss-server -c /etc/shadowsocks-libev/config.json &
rm -rf /etc/nginx/sites-enabled/default
nginx -g 'daemon off;'