forked from Snawoot/shadowsocks-heroku
-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
54 lines (43 loc) · 1.34 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
#!/bin/bash
if [[ -z "${PASSWORD}" ]]; then
export PASSWORD="5c301bb8-6c77-41a0-a606-4ba11bbab084"
fi
echo ${PASSWORD}
export PASSWORD_JSON="$(echo -n "$PASSWORD" | jq -Rc)"
if [[ -z "${ENCRYPT}" ]]; then
export ENCRYPT="chacha20-ietf-poly1305"
fi
if [[ -z "${V2_Path}" ]]; then
export V2_Path="s233"
fi
echo ${V2_Path}
if [[ -z "${QR_Path}" ]]; then
export QR_Path="/qr_img"
fi
echo ${QR_Path}
case "$AppName" in
*.*)
export DOMAIN="$AppName"
;;
*)
export DOMAIN="$AppName.herokuapp.com"
;;
esac
bash /conf/shadowsocks-libev_config.json > /etc/shadowsocks-libev/config.json
echo /etc/shadowsocks-libev/config.json
cat /etc/shadowsocks-libev/config.json
bash /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 "Do not generate QR-code"
else
[ ! -d /wwwroot/${QR_Path} ] && mkdir /wwwroot/${QR_Path}
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/${QR_Path}/index.html
echo -n "${ss}" | qrencode -s 6 -o /wwwroot/${QR_Path}/vpn.png
fi
ss-server -c /etc/shadowsocks-libev/config.json &
rm -rf /etc/nginx/sites-enabled/default
nginx -g 'daemon off;'