forked from ygcaicn/Xray-heroku
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·97 lines (82 loc) · 2.3 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
95
96
97
#!/bin/bash
#Xray版本
if [[ -z "${VER}" ]]; then
VER="latest"
fi
echo ${VER}
if [[ -z "${Vless_Path}" ]]; then
Vless_Path="/s233"
fi
echo ${Vless_Path}
if [[ -z "${Vless_UUID}" ]]; then
Vless_UUID="5c301bb8-6c77-41a0-a606-4ba11bbab084"
fi
echo ${Vless_UUID}
if [[ -z "${Vmess_Path}" ]]; then
Vmess_Path="/s244"
fi
echo ${Vmess_Path}
if [[ -z "${Vmess_UUID}" ]]; then
Vmess_UUID="5c301bb8-6c77-41a0-a606-4ba11bbab084"
fi
echo ${Vmess_UUID}
if [[ -z "${Share_Path}" ]]; then
Share_Path="/share233"
fi
echo ${Share_Path}
if [ "$VER" = "latest" ]; then
VER=`wget -qO- "https://api.github.com/repos/XTLS/Xray-core/releases/latest" | sed -n -r -e 's/.*"tag_name".+?"([vV0-9\.]+?)".*/\1/p'`
[[ -z "${VER}" ]] && VER="v1.2.2"
else
VER="v$VER"
fi
mkdir /xraybin
cd /xraybin
RAY_URL="https://github.com/XTLS/Xray-core/releases/download/${VER}/Xray-linux-64.zip"
echo ${RAY_URL}
wget --no-check-certificate ${RAY_URL}
unzip Xray-linux-64.zip
rm -f Xray-linux-64.zip
chmod +x ./xray
ls -al
cd /wwwroot
tar xvf wwwroot.tar.gz
rm -rf wwwroot.tar.gz
sed -e "/^#/d"\
-e "s/\${Vless_UUID}/${Vless_UUID}/g"\
-e "s|\${Vless_Path}|${Vless_Path}|g"\
-e "s/\${Vmess_UUID}/${Vmess_UUID}/g"\
-e "s|\${Vmess_Path}|${Vmess_Path}|g"\
/conf/Xray.template.json > /xraybin/config.json
echo /xraybin/config.json
cat /xraybin/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|\${Vless_Path}|${Vless_Path}|g"\
-e "s|\${Vmess_Path}|${Vmess_Path}|g"\
-e "s|\${Share_Path}|${Share_Path}|g"\
-e "$s"\
/conf/nginx.template.conf > /etc/nginx/conf.d/ray.conf
echo /etc/nginx/conf.d/ray.conf
cat /etc/nginx/conf.d/ray.conf
[ ! -d /wwwroot/${Share_Path} ] && mkdir -p /wwwroot/${Share_Path}
sed -e "/^#/d"\
-e "s|\${_Vless_Path}|${Vless_Path}|g"\
-e "s|\${_Vmess_Path}|${Vmess_Path}|g"\
-e "s/\${_Vless_UUID}/${Vless_UUID}/g"\
-e "s/\${_Vmess_UUID}/${Vmess_UUID}/g"\
-e "$s"\
/conf/share.html > /wwwroot/${Share_Path}/index.html
echo /wwwroot/${Share_Path}/index.html
cat /wwwroot/${Share_Path}/index.html
cd /xraybin
./xray run -c ./config.json &
rm -rf /etc/nginx/sites-enabled/default
nginx -g 'daemon off;'