-
Notifications
You must be signed in to change notification settings - Fork 361
/
caddy.sh
executable file
·91 lines (85 loc) · 1.5 KB
/
caddy.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
#!/bin/bash
# FILE="/etc/Caddy"
domain="$1"
psname="$2"
uuid="51be9a06-299f-43b9-b713-1ec5eb76e3d7"
if [ ! "$3" ] ;then
uuid=$(uuidgen)
echo "uuid 将会系统随机生成"
else
uuid="$3"
fi
cat > /etc/Caddyfile <<'EOF'
domain
{
log ./caddy.log
proxy /one :2333 {
websocket
header_upstream -Origin
}
}
EOF
sed -i "s/domain/${domain}/" /etc/Caddyfile
# v2ray
cat > /etc/v2ray/config.json <<'EOF'
{
"inbounds": [
{
"port": 2333,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "uuid",
"alterId": 64
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/one"
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}
EOF
sed -i "s/uuid/${uuid}/" /etc/v2ray/config.json
cat > /srv/sebs.js <<'EOF'
{
"add":"domain",
"aid":"0",
"host":"",
"id":"uuid",
"net":"ws",
"path":"/one",
"port":"443",
"ps":"sebsclub",
"tls":"tls",
"type":"none",
"v":"2"
}
EOF
if [ "$psname" != "" ] && [ "$psname" != "-c" ]; then
sed -i "s/sebsclub/${psname}/" /srv/sebs.js
sed -i "s/domain/${domain}/" /srv/sebs.js
sed -i "s/uuid/${uuid}/" /srv/sebs.js
else
$*
fi
pwd
cp /etc/Caddyfile .
nohup /bin/parent caddy --log stdout --agree=false &
echo "配置 JSON 详情"
echo " "
cat /etc/v2ray/config.json
echo " "
node v2ray.js
/usr/bin/v2ray -config /etc/v2ray/config.json