-
Notifications
You must be signed in to change notification settings - Fork 686
/
entrypoint.sh
executable file
·85 lines (70 loc) · 2.38 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
#!/bin/bash
[[ -z "${MY_TOKEN}" ]] && MY_TOKEN="2023"
[[ -z "${REPO}" ]] && REPO="v2fly/v2ray-core"
[[ -z "${VER}" ]] && VER="latest"
[[ -z "${Vless_Path}" ]] && Vless_Path=/l`echo $MY_TOKEN | md5sum | cut -c 1-9`
[[ -z "${Vless_UUID}" ]] && Vless_UUID="5c301bb8-6c77-41a0-a606-4ba11bbab084"
[[ -z "${Vmess_Path}" ]] && Vmess_Path=/m`echo $MY_TOKEN | md5sum | cut -c 1-9`
[[ -z "${Vmess_UUID}" ]] && Vmess_UUID="5c301bb8-6c77-41a0-a606-4ba11bbab084"
[[ -z "${Share_Path}" ]] && Share_Path=/share_${MY_TOKEN}
[[ -z "${PORT}" ]] && PORT=80
echo $Share_Path
if [ "$VER" = "latest" ]; then
VER=`wget -qO- "https://api.github.com/repos/${REPO}/releases/latest" | sed -n -r -e 's/.*"tag_name".+?"([vV0-9\.]+?)".*/\1/p'`
else
VER="v$VER"
fi
if [ "$REPO" = "v2fly/v2ray-core" ]; then
PACKAGE="v2ray-linux-64.zip"
else
PACKAGE="Xray-linux-64.zip"
fi
mkdir /raybin && cd /raybin
RAY_URL="https://github.com/${REPO}/releases/download/${VER}/${PACKAGE}"
echo ${RAY_URL}
wget --no-check-certificate ${RAY_URL}
unzip $PACKAGE
rm -f $PACKAGE
BIN=`ls *ray`
chmod +x ./$BIN
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/ray.template.json > /raybin/config.json
echo /raybin/config.json
cat /raybin/config.json
if [[ -z "${ProxySite}" ]]; then
s="s|#ProxySite|#no ProxySite|g"
echo "site:use local wwwroot html"
else
s="s|#ProxySite|proxy_pass https://${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"\
/conf/share.html > /wwwroot/${Share_Path}/index.html
echo /wwwroot/${Share_Path}/index.html
cat /wwwroot/${Share_Path}/index.html
cd /raybin
./$BIN run -c ./config.json &
rm -rf /etc/nginx/sites-enabled/default
nginx -g 'daemon off;'