forked from alicepear/kuhero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
89 lines (76 loc) · 2.89 KB
/
start.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
#!/bin/sh
### update
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && apk update
### caddy
apk add --no-cache caddy
mkdir -p /usr/share/caddy && wget -O /usr/share/caddy/index.html $CADDYIndexPage
cat << EOF > /etc/caddy/Caddyfile
:$PORT
root * /usr/share/caddy
file_server
@websocket_ss {
header Connection *Upgrade*
header Upgrade websocket
path $SSPATH
}
reverse_proxy @websocket_ss 127.0.0.1:1234
@websocket_gost {
header Connection *Upgrade*
header Upgrade websocket
path $GOSTPATH
}
reverse_proxy @websocket_gost 127.0.0.1:2234
@websocket_brook {
header Connection *Upgrade*
header Upgrade websocket
path $BROOKPATH
}
reverse_proxy @websocket_brook 127.0.0.1:3234
@websocket_v2ray {
header Connection *Upgrade*
header Upgrade websocket
path $V2RAYPATH
}
reverse_proxy @websocket_v2ray 127.0.0.1:4234
EOF
[[ "$CADDYCONFIG" != "" ]] && wget -O /etc/caddy/Caddyfile $CADDYCONFIG && sed -i "1c :$PORT" /etc/caddy/Caddyfile
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile &
### tor
[[ "$TOREnable" == "true" ]] && apk add --no-cache tor && tor &
### v2ray
if [[ "$V2RAYEnable" == "true" ]]; then
wget -qO- https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-linux-64.zip | busybox unzip - && chmod +x /v2ray /v2ctl
cat << EOF > /v2ray.json
{
"inbounds":
[
{
"port": 4234,"listen": "127.0.0.1","protocol": "$V2RAYPROTOCOL",
"settings": {"clients": [{"id": "$AUUID"}],"decryption": "none"},
"streamSettings": {"network": "ws","wsSettings": {"path": "$V2RAYPATH"}}
}
],
"outbounds": [{"protocol": "freedom"}]
}
EOF
[[ "$V2RAYCONFIG" != "" ]] && wget -O /v2ray.json $V2RAYCONFIG
/v2ray -config /v2ray.json &
fi
### shadowsocks
if [[ "$SSEnable" == "true" ]]; then
apk add --no-cache shadowsocks-libev
v2rayplugin_URL="$(wget -qO- https://api.github.com/repos/shadowsocks/v2ray-plugin/releases/latest | grep -E "browser_download_url.*linux-amd64" | cut -f4 -d\")"
wget -O - $v2rayplugin_URL | tar -xz -C /usr/bin/ && chmod +x /usr/bin/v2ray-plugin_linux_amd64
ss-server -s 127.0.0.1 -p 1234 -k $APASSWORD -m $SSENCYPT --plugin /usr/bin/v2ray-plugin_linux_amd64 --plugin-opts "server;path=$SSPATH" &
fi
### gost
if [[ "$GOSTEnable" == "true" ]]; then
gost_URL="$(wget -qO- https://api.github.com/repos/ginuerzh/gost/releases/latest | grep -E "browser_download_url.*linux-amd64" | cut -f4 -d\")"
wget -O - $gost_URL | gzip -d > /usr/bin/gost && chmod +x /usr/bin/gost
[[ "$GOSTMETHOD" == "" ]] && gost -L ss+ws://AEAD_CHACHA20_POLY1305:$APASSWORD@127.0.0.1:2234?path=$GOSTPATH & || gost $GOSTMETHOD &
fi
### brook
if [[ "$BROOKEnable" == "true" ]]; then
wget -O /usr/bin/brook https://github.com/txthinking/brook/releases/latest/download/brook_linux_amd64 && chmod +x /usr/bin/brook
brook wsserver -l 127.0.0.1:3234 --path $BROOKPATH -p $APASSWORD &
fi