-
Notifications
You must be signed in to change notification settings - Fork 0
/
get.sh
executable file
·96 lines (82 loc) · 1.91 KB
/
get.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
#!/bin/bash
set -x
arch=amd64
case $(uname -m) in
aarch64 )
arch=arm64
;;
arm* )
arch=armv5
if readelf -A /bin/sh | grep -q 'VFP registers'; then
arch=armv7
fi
;;
esac
domain=$(curl -sS whatismyip.akamai.com | tr . -).nip.io
checksum=$(curl https://phus.lu/liner/checksums.txt | grep -E "liner_linux_${arch}-[0-9]+.tar.xz")
filename=$(echo $checksum | awk '{print $2}')
pacfile=$(shuf -er -n6 1 2 3 4 5 6 7 8 9 | tr -d '\n').pac
if test -d liner; then
cd liner
elif test -x liner.sh; then
true
else
mkdir liner && cd liner
fi
curl http://phus.lu/liner/$filename > $filename
if test "$(sha1sum $filename)" != "$checksum"; then
echo "$filename sha1sum mismatched, please check your network!"
rm -rf $filename
exit 1
fi
tar xvJf $filename
rm -rf $filename
if test -f production.yaml; then
exit 0
fi
cat <<EOF > production.yaml
global:
log_level: info
max_idle_conns: 100
dial_timeout: 30
dns_cache_duration: 15m
https:
- listen: [':443']
server_name: ['$domain']
forward:
log: true
prefer_ipv6: false
policy: |
{{if all (.Request.ProtoAtLeast 2 0) (eq .Request.TLS.Version 0x0304) (greased .ClientHelloInfo)}}
bypass_auth
{{else}}
proxy_pass
{{end}}
web:
- location: /$pacfile
index:
file: $(pwd)/$pacfile
- location: /
proxy:
pass: 'http://127.0.0.1:80'
EOF
cat <<EOF > liner.service
[Unit]
Wants=network-online.target
After=network.target network-online.target
Description=liner
[Service]
Type=forking
KillMode=process
WorkingDirectory=$(pwd)
ExecStart=$(pwd)/liner.sh start
ExecStop=$(pwd)/liner.sh stop
ExecReload=$(pwd)/liner.sh reload
[Install]
WantedBy=multi-user.target
EOF
echo ENV=production > .env
mv china.pac $pacfile
sudo ./liner.sh restart
hash systemctl 2>/dev/null && sudo systemctl enable $(pwd)/liner.service
echo "https://$domain/$pacfile"