-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathssrp.sh
49 lines (41 loc) · 1.5 KB
/
ssrp.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
#!/bin/bash
[[ ! -d "/paniy/cloudflare" ]] && mkdir -p /paniy/cloudflare
cd /paniy/cloudflare
opkg install jq
arch=$(uname -m)
if [[ ${arch} =~ "x86" ]]; then
tag="amd"
[[ ${arch} =~ "64" ]] && tag="amd64"
elif [[ ${arch} =~ "aarch" ]]; then
tag="arm"
[[ ${arch} =~ "64" ]] && tag="arm64"
else
exit 1
fi
version=$(curl -s https://api.github.com/repos/XIU2/CloudflareSpeedTest/tags | jq -r .[].name | head -1)
old_version=$(cat CloudflareST_version.txt )
if [[ ! -f "CloudflareST" || ${version} != ${old_version} ]]; then
rm -rf CloudflareST_linux_${tag}.tar.gz
wget -N https://github.com/XIU2/CloudflareSpeedTest/releases/download/${version}/CloudflareST_linux_${tag}.tar.gz
echo "${version}" > CloudflareST_version.txt
tar -xvf CloudflareST_linux_${tag}.tar.gz
chmod +x CloudflareST
fi
##注意修改!!!
/etc/init.d/shadowsocksr stop
wait
./CloudflareST -dn 10 -tll 40 -o cf_result.txt
wait
sleep 3
if [[ -f "cf_result.txt" ]]; then
first=$(sed -n '2p' cf_result.txt | awk -F ',' '{print $1}') && echo $first >>ip-all.txt
second=$(sed -n '3p' cf_result.txt | awk -F ',' '{print $1}') && echo $second >>ip-all.txt
third=$(sed -n '4p' cf_result.txt | awk -F ',' '{print $1}') && echo $third >>ip-all.txt
wait
##注意修改 [0]中的0改成你ssr服务器所在的位置,不知道的可以用 uci show shadowsocksr命令查看
uci set shadowsocksr.@servers[0].server=${first}
wait
uci commit shadowsocksr
wait
[[ $(/etc/init.d/shadowsocksr status) != "running" ]] && /etc/init.d/shadowsocksr start
fi