Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejun committed Dec 31, 2024
1 parent 602fa02 commit 49a36f9
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions revive.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
#!/bin/bash

AUTOUPDATE=${AUTOUPDATE:-Y}
SENDTYPE=${SENDTYPE:-null}
TELEGRAM_TOKEN=${TELEGRAM_TOKEN:-null}
TELEGRAM_USERID=${TELEGRAM_USERID:-null}
WXSENDKEY=${WXSENDKEY:-null}
BUTTON_URL=${BUTTON_URL:-null}

# 使用 jq 提取 JSON 数组,并将其加载为 Bash 数组
hosts_info=($(echo "${HOSTS_JSON}" | jq -c ".info[]"))

for info in "${hosts_info[@]}"; do
user=$(echo $info | jq -r ".username")
host=$(echo $info | jq -r ".host")
port=$(echo $info | jq -r ".port")
pass=$(echo $info | jq -r ".password")

if [[ "$AUTOUPDATE" == "Y" ]]; then
script="/home/$user/serv00-play/keepalive.sh autoupdate ${SENDTYPE} \"${TELEGRAM_TOKEN}\" \"${TELEGRAM_USERID}\" \"${WXSENDKEY}\" \"${BUTTON_URL}\" \"${pass}\""
else
script="/home/$user/serv00-play/keepalive.sh noupdate ${SENDTYPE} \"${TELEGRAM_TOKEN}\" \"${TELEGRAM_USERID}\" \"${WXSENDKEY}\" \"${BUTTON_URL}\" \"${pass}\""
fi
output=$(sshpass -p "$pass" ssh -o StrictHostKeyChecking=no -p "$port" "$user@$host" "bash -s" <<<"$script")

echo "output:$output"
if echo "$output" | grep -q "keepalive.sh"; then
echo "登录成功"
else
echo "登录失败"
./tgsend.sh "Host:$host,user:$user,登录失败请检查!"
fi
done
#!/bin/bash

AUTOUPDATE=${AUTOUPDATE:-Y}
SENDTYPE=${SENDTYPE:-null}
TELEGRAM_TOKEN=${TELEGRAM_TOKEN:-null}
TELEGRAM_USERID=${TELEGRAM_USERID:-null}
WXSENDKEY=${WXSENDKEY:-null}
BUTTON_URL=${BUTTON_URL:-null}

# 使用 jq 提取 JSON 数组,并将其加载为 Bash 数组
hosts_info=($(echo "${HOSTS_JSON}" | jq -c ".info[]"))

for info in "${hosts_info[@]}"; do
user=$(echo $info | jq -r ".username")
host=$(echo $info | jq -r ".host")
port=$(echo $info | jq -r ".port")
pass=$(echo $info | jq -r ".password")

if [[ "$AUTOUPDATE" == "Y" ]]; then
script="/home/$user/serv00-play/keepalive.sh autoupdate ${SENDTYPE} \"${TELEGRAM_TOKEN}\" \"${TELEGRAM_USERID}\" \"${WXSENDKEY}\" \"${BUTTON_URL}\" \"${pass}\""
else
script="/home/$user/serv00-play/keepalive.sh noupdate ${SENDTYPE} \"${TELEGRAM_TOKEN}\" \"${TELEGRAM_USERID}\" \"${WXSENDKEY}\" \"${BUTTON_URL}\" \"${pass}\""
fi
output=$(sshpass -p "$pass" ssh -o StrictHostKeyChecking=no -p "$port" "$user@$host" "bash -s" <<<"$script")

echo "output:$output"
if echo "$output" | grep -q "keepalive.sh"; then
echo "登录成功"
else
echo "登录失败"
./tgsend.sh "Host:$host,user:$user,登录失败请检查!"
fi
done

0 comments on commit 49a36f9

Please sign in to comment.