全球主机交流论坛
标题:
Google one 扶墙安卓 自动重连脚本。
[打印本页]
作者:
night007
时间:
2023-11-1 17:15
标题:
Google one 扶墙安卓 自动重连脚本。
有时候遇到g1v偶尔断线后自动重连不太好使,给需要的人。可以用termux:boot 设置开机自启,楼主现在扔软路由上运行的
#!/bin/sh
G1V_ACTIVITY="com.google.android.apps.subscriptions.red/com.google.android.apps.subscriptions.red.main.MainActivity"
TERMUX_ACTIVITY="com.termux/com.termux.app.TermuxActivity"
SERVICE="com.google.android.apps.subscriptions.red/com.google.android.libraries.privacy.ppn.Ppn扶墙Service"
STOP_扶墙_COMMAND="am broadcast -a stop -n com.google.android.apps.subscriptions.red/com.google.android.apps.subscriptions.red.ppn.DisablePpnReceiver_Receiver"
function restart_service() {
echo "$(date) - 操作: 正在关闭扶墙服务..."
$STOP_扶墙_COMMAND
echo "$(date) - 结果: 扶墙服务已关闭"
sleep 1
echo "$(date) - 操作: 正在重启服务..."
OUTPUT=$(am startservice -n "$SERVICE" 2>&1)
# 检查google one应用是否已打开"
if [[ $OUTPUT == *"Error"* ]]; then
#打开Google one
am start -n $G1V_ACTIVITY
am startservice -n "$SERVICE"
fi
echo "$(date) - 结果: 服务已重启"
}
tun0_missing_counter=0
while true; do
if ! dumpsys activity | grep "$SERVICE" > /dev/null; then
echo "$(date) - 服务状态: 关闭"
restart_service
sleep 10
continue
fi
if ip a | grep -q tun0; then
echo "$(date) - 网络状态: tun0接口存在"
sleep 5
else
echo "$(date) - 网络状态: tun0接口不存在"
tun0_missing_counter=$((tun0_missing_counter + 1))
fi
if [ $tun0_missing_counter -ge 3 ]; then
echo "$(date) - 警告: tun0已经超过30秒不存在"
restart_service
tun0_missing_counter=0
fi
sleep 5
done
复制代码
作者:
xiF
时间:
2023-11-1 17:16
支持技术贴
作者:
ziyo
时间:
2023-11-1 17:29
感谢大佬技术分享
作者:
zxhawk
时间:
2023-11-1 17:57
能不能出点详细教程。
Send by DZ Reader
作者:
hcyme
时间:
2023-11-1 18:15
刚刚下车
作者:
wjcwukong
时间:
2023-11-18 10:22
mark
作者:
8
时间:
2023-11-18 10:26
厉害了
欢迎光临 全球主机交流论坛 (https://443502.xyz/)
Powered by Discuz! X3.4