This repository has been archived by the owner on Oct 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathentrypoint.sh
146 lines (128 loc) · 3.36 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#! /bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
######################################################
# Anything wrong? Contact me via telegram: @CN_SZTL. #
######################################################
if [[ -z "${AppName}" ]]; then
AppName="no"
fi
if [[ -z "${Level}" ]]; then
Level="1"
fi
if [[ -z "${UUID}" ]]; then
if [ "$AppName" = "no" ]; then
UUID="4890bd47-5180-4b1c-9a5d-3ef686543112"
else
UUID="$(uuid)"
fi
fi
if [[ -z "${AlterID}" ]]; then
AlterID="10"
fi
if [[ -z "${V2_Path}" ]]; then
V2_Path="/shellscript"
fi
if [[ -z "${V2_QR_Path}" ]]; then
V2_QR_Code="subscription"
fi
rm -f "/etc/localtime"
cp "/usr/share/zoneinfo/Asia/Shanghai" "/etc/localtime"
System_bit="$(getconf LONG_BIT)"
[[ "${System_bit}" == "32" ]] && dl_version="386"
[[ "${System_bit}" == "64" ]] && dl_version="amd64"
if [ "$VER" = "latest" ]; then
v2ray_version="$(wget -qO- "https://api.github.com/repos/v2ray/v2ray-core/releases/latest" | grep "tag_name" | cut -d\" -f4)"
else
v2ray_version="v$VER"
fi
mkdir "/v2raybin"
cd "/v2raybin"
wget -qO "v2ray.zip" "https://github.com/v2ray/v2ray-core/releases/download/${v2ray_version}/v2ray-linux-${System_bit}.zip"
unzip "v2ray.zip"
rm -f "v2ray.zip"
chmod +x "/v2raybin/v2ray-${v2ray_version}-linux-${System_bit}/*"
mkdir "/caddybin"
cd "/caddybin"
wget -qO "caddy.tar.gz" "https://caddyserver.com/download/linux/${dl_version}?plugins=http.forwardproxy&license=personal"
tar xvf "caddy.tar.gz"
rm -f "caddy.tar.gz"
chmod +x "caddy"
cd "/root"
mkdir "/wwwroot"
cd "/wwwroot"
wget -qO "demo.tar.gz" "https://github.com/shell-script/v2ray-heroku/raw/master/demo.tar.gz"
tar xvf "demo.tar.gz"
rm -f "demo.tar.gz"
cat <<-EOF > "/v2raybin/v2ray-${v2ray_version}-linux-${System_bit}/config.json"
{
"log":{
"loglevel":"warning"
},
"inbound":{
"protocol":"vmess",
"listen":"127.0.0.1",
"port":10000,
"settings":{
"clients":[
{
"id":"${UUID}",
"level":${Level},
"alterId":${AlterID}
}
]
},
"streamSettings":{
"network":"ws",
"wsSettings":{
"path":"${V2_Path}"
}
}
},
"outbound":{
"protocol":"freedom",
"settings":{
}
}
}
EOF
cat <<-EOF > "/caddybin/Caddyfile"
http://0.0.0.0:${PORT}
{
root /wwwroot
index index.html index.txt
timeouts none
proxy ${V2_Path} localhost:10000 {
websocket
header_upstream -Origin
}
}
EOF
cat <<-EOF > "/v2raybin/vmess.json"
{
"v": "2",
"ps": "${AppName}.herokuapp.com",
"add": "${AppName}.herokuapp.com",
"port": "443",
"id": "${UUID}",
"aid": "${AlterID}",
"net": "ws",
"type": "none",
"host": "",
"path": "${V2_Path}",
"tls": "tls"
}
EOF
if [ "$AppName" = "no" ]; then
rm -f "/v2raybin/vmess.json"
else
mkdir "/wwwroot/${V2_QR_Path}"
vmess="vmess://$(cat /v2raybin/vmess.json | base64 -w 0)"
Linkbase64="$(echo -n "${vmess}" | tr -d "\n" | base64 -w 0) "
echo "${Linkbase64}" | tr -d "\n" > "/wwwroot/${V2_QR_Path}/index.txt"
echo -n "${vmess}" | qrencode -s 6 -o "/wwwroot/${V2_QR_Path}/qrcode.png"
fi
cd "/v2raybin/v2ray-${v2ray_version}-linux-${System_bit}"
./v2ray &
cd "/caddybin"
./caddy -conf="Caddyfile"