~重写保守模式启动函数,现在启动停止不会有额外kill命令报错,并且增加了对tg_bot脚本的启动支持

~新增tg_bot脚本的定时任务守护进程功能
~新增公网防火墙禁用时的警告确认功能
~优化小米路由自启脚本,现在自启脚本单独存放为/data/shellcrash_init.sh,且在卸载脚本时会保留改脚本并保留软固化功能
~优化小米自动清理功能,适配更多设备
~修复本地自解压安装时脚本报错bug
~修复小米等设备无法使用tg_bot控制机器人的问题
This commit is contained in:
juewuy
2025-12-27 17:32:40 +08:00
parent 8c7a5bec47
commit 1a273ec274
10 changed files with 109 additions and 62 deletions

View File

@@ -81,7 +81,12 @@ set_fw_wan() {
read -p "请输入对应数字 > " num
case $num in
1)
[ "$fw_wan" = ON ] && fw_wan=OFF || fw_wan=ON
if [ "$fw_wan" = ON ];then
read -p "确认关闭防火墙?这会带来极大的安全隐患!(1/0) > " res
[ "$res" = 1 ] && fw_wan=OFF || fw_wan=ON
else
fw_wan=ON
fi
setconfig fw_wan "$fw_wan"
set_fw_wan
;;
@@ -156,13 +161,10 @@ set_bot_tg_init(){
set_bot_tg_service(){
if [ "$bot_tg_service" = ON ];then
bot_tg_service=OFF
[ -f "$TMPDIR/bot_tg.pid" ] && kill -TERM -"$(cat "$TMPDIR/bot_tg.pid")" && rm -f "$TMPDIR/bot_tg.pid"
. "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_stop
else
bot_tg_service=ON
[ -n "$(pidof CrashCore)" ] && {
setsid sh "$CRASHDIR/menus/bot_tg.sh" &
echo $! > "$TMPDIR/bot_tg.pid"
}
[ -n "$(pidof CrashCore)" ] && . "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_start
fi
setconfig bot_tg_service "$bot_tg_service"
}

View File

@@ -0,0 +1,13 @@
. "$CRASHDIR"/libs/set_cron.sh
bot_tg_start(){
. "$CRASHDIR"/starts/start_legacy.sh
start_legacy "$CRASHDIR/menus/bot_tg.sh" 'bot_tg'
cronset 'TG_BOT守护进程' "*/10 * * * * /bin/sh $CRASHDIR/starts/start_legacy_wd.sh bot_tg #ShellCrash-TG_BOT守护进程"
}
bot_tg_stop(){
cronset 'TG_BOT守护进程'
[ -f "$TMPDIR/bot_tg.pid" ] && kill -TERM "$(cat "$TMPDIR/bot_tg.pid")"
rm -f "$TMPDIR/bot_tg.pid"
}

View File

@@ -2,6 +2,7 @@
# Copyright (C) Juewuy
. /tmp/SC_tmp/libs/check_dir_avail.sh
[ -n "$(echo -e | grep e)" ] && echo=echo || echo='echo -e'
set_crashdir() {
set_usb_dir() {

View File

@@ -54,8 +54,6 @@ uninstall() {
userdel -r shellcrash 2>/dev/null
nvram set script_usbmount="" 2>/dev/null
nvram commit 2>/dev/null
uci delete firewall.ShellCrash 2>/dev/null
uci commit firewall 2>/dev/null
echo "-----------------------------------------------"
echo -e "\033[36m已卸载ShellCrash相关文件有缘再会\033[0m"
echo -e "\033[33m请手动关闭当前窗口以重置环境变量\033[0m"