-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathrevive_node.sh
68 lines (60 loc) · 2.38 KB
/
revive_node.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
#!/bin/bash
toBase64() {
echo -n "$1" | base64
}
AUTOUPDATE=${AUTOUPDATE:-Y}
SENDTYPE=${SENDTYPE:-null}
TELEGRAM_TOKEN=${TELEGRAM_TOKEN:-null}
TELEGRAM_USERID=${TELEGRAM_USERID:-null}
WXSENDKEY=${WXSENDKEY:-null}
BUTTON_URL=${BUTTON_URL:-null}
LOGININFO=${LOGININFO:-Y}
TOKEN=${TOKEN:-""}
TOKEN=$(toBase64 $TOKEN)
base64_TELEGRAM_TOKEN=$(toBase64 $TELEGRAM_TOKEN)
Base64BUTTON_URL=$(toBase64 $BUTTON_URL)
export TELEGRAM_TOKEN TELEGRAM_USERID BUTTON_URL
# 使用 jq 提取 JSON 数组,并将其加载为 Bash 数组
hosts_info=($(echo "${HOSTS_JSON}" | jq -c ".info[]"))
summary=""
for info in "${hosts_info[@]}"; do
user=$(echo $info | jq -r ".username")
host=$(echo $info | jq -r ".host")
pass=$(echo $info | jq -r ".password")
echo "host: $host"
bas64_pass=$(toBase64 $pass)
output=$(curl -s -o /dev/null -w "%{http_code}" "https://$user.serv00.net/keep?token=$TOKEN&autoupdate=$AUTOUPDATE&sendtype=$SENDTYPE&telegramtoken=$base64_TELEGRAM_TOKEN&telegramuserid=$TELEGRAM_USERID&wxsendkey=$WXSENDKEY&buttonurl=$Base64BUTTON_URL&password=$bas64_pass")
if [ "$output" -eq 200 ]; then
echo "连接成功,账号正常"
msg="🟢主机 ${host}, 用户 ${user}, 连接成功,账号正常!\n"
elif [ "$output" -eq 403 ]; then
echo "账号被封"
msg="🔴主机 ${host}, 用户 ${user}, 账号被封!\n"
chmod +x ./tgsend.sh
export PASS=$pass
./tgsend.sh "Host:$host, user:$user, 账号被封,请检查!"
elif [ "$output" -eq 404 ]; then
echo "keepalive服务不在线"
msg="🔴主机 ${host}, 用户 ${user}, keepalive服务不在线!\n"
chmod +x ./tgsend.sh
export PASS=$pass
./tgsend.sh "Host:$host, user:$user, keepalive服务不在线,请检查!"
elif [ "$output" -eq 401 ]; then
echo "授权码错误"
msg="🔴主机 ${host}, 用户 ${user}, 授权码错误!\n"
chmod +x ./tgsend.sh
export PASS=$pass
./tgsend.sh "Host:$host, user:$user, 授权码错误,请检查!"
else
echo "连接失败,可能网络问题!"
msg="🔴主机 ${host}, 用户 ${user}, 连接失败,可能网络问题!\n"
chmod +x ./tgsend.sh
export PASS=$pass
./tgsend.sh "Host:$host, user:$user, 连接失败,可能网络问题,可直接访问主页查看: https://$user.serv00.net"
fi
summary=$summary$(echo -n $msg)
done
if [[ "$LOGININFO" == "Y" ]]; then
chmod +x ./tgsend.sh
./tgsend.sh "$summary"
fi