24 Commits

Author SHA1 Message Date
juewuy
7d2e1c54c4 Merge branch 'stable' of https://github.com/juewuy/ShellCrash into master 2026-02-02 20:25:42 +08:00
juewuy
f3cd3ff18a ~1.9.4r4 pkg 2026-02-02 20:25:14 +08:00
juewuy
1196557d4c ~修复部分任务命令执行失败的bug 2026-02-02 20:21:53 +08:00
juewuy
1af6cf36d2 ~修复部分情况下配置文件拉取失败的bug 2026-02-02 20:15:53 +08:00
juewuy
1f59a971cf ~修复部分小米设备Tproxy自启失效的bug 2026-02-02 20:13:04 +08:00
juewuy
9cad2c21e8 ~优化定时任务日志记录 2026-02-02 20:04:53 +08:00
juewuy
0b1d297622 ~修复华硕padavan小米等设备因意外循环重启的bug 2026-02-02 20:02:02 +08:00
juewuy
0ca7bb8eb2 ~现在跳过证书验证开关对内置下载工具也有效 2026-02-02 19:30:43 +08:00
juewuy
1bd16b5ca6 ~重写 set_cron.sh 尝试修复因为定时任务导致系统crontab内容丢失的问题 2026-02-02 19:23:03 +08:00
juewuy
88ae50bc43 Merge pull request #1192 from juewuy/master
~1.9.4r3 pkg
2026-01-31 20:25:20 +08:00
juewuy
3682a99a79 ~bug fix 2026-01-31 18:07:26 +08:00
juewuy
1129eb79b5 ~1.9.4r3 pkg 2026-01-31 17:59:04 +08:00
juewuy
dfae7195b3 ~修复TG-BOT无法使用自定义命令呼出的bug 2026-01-31 17:42:07 +08:00
juewuy
da23b70ca4 ~singbox内核改为默认启用sniff 2026-01-31 17:34:50 +08:00
juewuy
70bd8ed591 ~修复局域网过滤显示异常 2026-01-31 17:30:18 +08:00
juewuy
b17286b73b ~优化定时任务实现,尝试修复意外清空定时任务内容的bug 2026-01-31 17:26:48 +08:00
juewuy
d63b75b790 ~修复TG-BOT无法正确设置版本号和路由状态的bug 2026-01-31 17:14:57 +08:00
juewuy
6170a0461d ~1.9.4r2 pkg
~修复小闪存模式启动失败的bug
2026-01-27 20:14:50 +08:00
juewuy
48705a0dd9 ~修复小闪存模式内核位置错乱的bug 2026-01-27 19:54:10 +08:00
juewuy
4a2a982c8d ~修复部分小米设备自启失败的bug 2026-01-27 19:33:31 +08:00
juewuy
6e41971725 ~1.9.4r1.3 pkg 2026-01-27 17:34:33 +08:00
juewuy
bbe711b1ce ~修复停止服务时未同步停止tg_bot进程的bug 2026-01-27 17:33:52 +08:00
juewuy
ee523035a6 ~1.9.4r1.2 pkg 2026-01-27 15:25:07 +08:00
juewuy
847010399d ~修复小米自启动失败的bug 2026-01-27 15:23:25 +08:00
20 changed files with 99 additions and 59 deletions

Binary file not shown.

View File

@@ -1,4 +1,4 @@
meta_v=v1.19.17 meta_v=v1.19.17
singboxr_v=1.13.0-alpha.27 singboxr_v=1.13.0-alpha.27
versionsh=1.9.4rc1.1 versionsh=1.9.4rc4
GeoIP_v=20251205 GeoIP_v=20251205

View File

@@ -23,7 +23,9 @@ core_unzip() { #$1:需要解压的文件 $2:目标文件名
} }
core_find(){ core_find(){
if [ ! -f "$TMPDIR"/CrashCore ];then if [ ! -f "$TMPDIR"/CrashCore ];then
core_dir=$(find "$BINDIR"/CrashCore.* $find_para 2>/dev/null) [ -n "$(find "$CRASHDIR"/CrashCore.* $find_para 2>/dev/null)" ] && [ "$CRASHDIR" != "$BINDIR" ] &&
mv -f "$CRASHDIR"/CrashCore.* "$BINDIR"/
core_dir=$(find "$BINDIR"/CrashCore.* $find_para 2>/dev/null | head -n 1)
[ -n "$core_dir" ] && core_unzip "$core_dir" CrashCore [ -n "$core_dir" ] && core_unzip "$core_dir" CrashCore
fi fi
} }
@@ -49,7 +51,12 @@ core_check(){
else else
mv -f "$1" "$BINDIR/CrashCore.$zip_type" mv -f "$1" "$BINDIR/CrashCore.$zip_type"
fi fi
mv -f "$TMPDIR/core_new" "$TMPDIR/CrashCore" if [ "$zip_type" = 'upx' ];then
rm -f "$1" "$TMPDIR"/core_new
ln -sf "$TMPDIR/CrashCore.upx" "$TMPDIR/CrashCore"
else
mv -f "$TMPDIR/core_new" "$TMPDIR/CrashCore"
fi
core_v="$v" core_v="$v"
setconfig COMMAND "$COMMAND" "$CRASHDIR"/configs/command.env && . "$CRASHDIR"/configs/command.env setconfig COMMAND "$COMMAND" "$CRASHDIR"/configs/command.env && . "$CRASHDIR"/configs/command.env
setconfig crashcore "$crashcore" setconfig crashcore "$crashcore"
@@ -73,7 +80,7 @@ core_webget(){
if [ "$?" = 0 ];then if [ "$?" = 0 ];then
core_check "$TMPDIR/Coretmp.$zip_type" core_check "$TMPDIR/Coretmp.$zip_type"
else else
rm -rf "$TMPDIR/Coretmp.$zip_type" rm -f "$TMPDIR/Coretmp.$zip_type"
return 1 return 1
fi fi
} }

View File

@@ -1,14 +1,15 @@
#日志工具 #日志工具
. "$CRASHDIR"/libs/web_json.sh . "$CRASHDIR"/libs/web_json.sh
#$1日志内容$2显示颜色$3是否推送 #$1日志内容$2显示颜色$3是否推送$4是否覆盖上一条
logger() { logger() {
TMPDIR=/tmp/ShellCrash TMPDIR=/tmp/ShellCrash
[ -n "$2" -a "$2" != 0 ] && printf "\033[%sm%s\033[0m\n" "$2" "$1" [ -n "$2" -a "$2" != 0 ] && printf "\033[%sm%s\033[0m\n" "$2" "$1"
log_text="$(date "+%G-%m-%d_%H:%M:%S")~$1" log_text="$(date "+%G-%m-%d_%H:%M:%S")~$1"
[ "$4" = on ] && sed -i "/$1/d" "$TMPDIR"/ShellCrash.log
echo "$log_text" >>"$TMPDIR"/ShellCrash.log echo "$log_text" >>"$TMPDIR"/ShellCrash.log
[ "$(wc -l "$TMPDIR"/ShellCrash.log | awk '{print $1}')" -gt 199 ] && sed -i '1,20d' "$TMPDIR"/ShellCrash.log [ "$(wc -l "$TMPDIR"/ShellCrash.log | awk '{print $1}')" -gt 199 ] && sed -i '1,20d' "$TMPDIR"/ShellCrash.log
#推送远程日志 #推送远程日志
[ -z "$3" ] && { [ "$3" != off ] && {
[ -n "$device_name" ] && log_text="$log_text($device_name)" [ -n "$device_name" ] && log_text="$log_text($device_name)"
[ -n "$push_TG" ] && { [ -n "$push_TG" ] && {
url="https://api.telegram.org/bot${push_TG}/sendMessage" url="https://api.telegram.org/bot${push_TG}/sendMessage"

View File

@@ -1,27 +1,38 @@
crondir="$(crond -h 2>&1 | grep -oE 'Default:.*' | awk -F ":" '{print $2}')" crondir="$(crond -h 2>&1 | grep -oE 'Default:.*' | awk -F ":" '{print $2}'| tr -d ' ')"
[ ! -w "$crondir" ] && crondir="/etc/storage/cron/crontabs" [ ! -w "$crondir" ] && crondir="/etc/storage/cron/crontabs"
[ ! -w "$crondir" ] && crondir="/var/spool/cron/crontabs" [ ! -w "$crondir" ] && crondir="/var/spool/cron/crontabs"
[ ! -w "$crondir" ] && crondir="/var/spool/cron" [ ! -w "$crondir" ] && crondir="/var/spool/cron"
tmpcron="$TMPDIR"/cron_tmp [ -z "$USER" ] && USER=$(whoami 2>/dev/null)
tmpcron=/tmp/cron_tmp
touch "$tmpcron"
croncmd() { #定时任务工具 cronadd() { #定时任务工具
if [ -n "$(crontab -h 2>&1 | grep '\-l')" ]; then if crontab -h 2>&1 | grep -q '\-l'; then
crontab "$1" crontab "$1"
elif [ -w "$crondir" ] && [ -n "$USER" ];then else
[ "$1" = "-l" ] && cat "$crondir"/"$USER" 2>/dev/null cat "$1" >"$crondir"/"$USER" && cru a REFRESH "0 0 1 1 * /bin/true" 2>/dev/null
[ -f "$1" ] && cat "$1" >"$crondir"/"$USER" fi
killall -HUP crond 2>/dev/null }
cronload() { #定时任务工具
if [ -f "$crondir/$USER" ];then
cat "$crondir"/"$USER" 2>/dev/null
elif crontab -h 2>&1 | grep -q '\-l'; then
crontab -l
else else
echo "找不到可用的crond或者crontab应用No available crond or crontab application can be found!" echo "找不到可用的crond或者crontab应用No available crond or crontab application can be found!"
fi fi
} }
cronset() { #定时任务设置 cronset() { #定时任务设置
# 参数1代表要移除的关键字,参数2代表要添加的任务语句 # 参数1代表要移除的关键字,参数2代表要添加的任务语句
croncmd -l >"$tmpcron" cronload | grep -v '^$' | grep -vF "$1" >"$tmpcron"
sed -i "/$1/d" "$tmpcron" [ -n "$2" ] && echo "$2" >>"$tmpcron"
sed -i '/^$/d' "$tmpcron" cronadd "$tmpcron"
echo "$2" >>"$tmpcron" #华硕/Padavan固件存档在本地,其他则删除
croncmd "$tmpcron" if [ -d /jffs ] || [ -d /etc/storage/ShellCrash ];then
rm -f "$tmpcron" mv -f "$tmpcron" "$CRASHDIR"/task/cron
else
rm -f "$tmpcron"
fi
sleep 1
} }

View File

@@ -13,18 +13,26 @@ webget(){
#参数【$1】代表下载目录【$2】代表在线地址 #参数【$1】代表下载目录【$2】代表在线地址
#参数【$3】代表输出显示【$4】不启用重定向 #参数【$3】代表输出显示【$4】不启用重定向
#参数【$5】代表验证证书【$6】使用自定义UA #参数【$5】代表验证证书【$6】使用自定义UA
[ -n "$6" ] && agent="--user-agent \"$6\"" [ -n "$6" ] && agent="--user-agent $6"
if wget --help 2>&1 | grep -q 'show-progress' >/dev/null 2>&1; then if wget --help 2>&1 | grep -q 'show-progress' >/dev/null 2>&1; then
[ "$3" = "echooff" ] && progress='-q' || progress='-q --show-progress' [ "$3" = "echooff" ] && progress='-q' || progress='-q --show-progress'
[ "$4" = "rediroff" ] && redirect='--max-redirect=0' || redirect='' [ "$4" = "rediroff" ] && redirect='--max-redirect=0' || redirect=''
[ "$5" = "skipceroff" ] && certificate='' || certificate='--no-check-certificate' if [ "$5" = "skipceroff" ] || [ "$skip_cert" = OFF ];then
certificate=''
else
certificate='--no-check-certificate'
fi
wget -Y on $agent $progress $redirect $certificate --timeout=3 -O "$1" "$url" && return 0 #成功则退出否则重试 wget -Y on $agent $progress $redirect $certificate --timeout=3 -O "$1" "$url" && return 0 #成功则退出否则重试
wget -Y off $agent $progress $redirect $certificate --timeout=5 -O "$1" "$2" wget -Y off $agent $progress $redirect $certificate --timeout=5 -O "$1" "$2"
return $? return $?
elif curl --version >/dev/null 2>&1; then elif curl --version >/dev/null 2>&1; then
[ "$3" = "echooff" ] && progress='-s' || progress='-#' [ "$3" = "echooff" ] && progress='-s' || progress='-#'
[ "$4" = "rediroff" ] && redirect='' || redirect='-L' [ "$4" = "rediroff" ] && redirect='' || redirect='-L'
[ "$5" = "skipceroff" ] && certificate='' || certificate='-k' if [ "$5" = "skipceroff" ] || [ "$skip_cert" = OFF ];then
certificate=''
else
certificate='-k'
fi
if curl --version | grep -q '^curl 8.' && ckcmd base64; then if curl --version | grep -q '^curl 8.' && ckcmd base64; then
auth_b64=$(printf '%s' "$authentication" | base64) auth_b64=$(printf '%s' "$authentication" | base64)
result=$(curl $agent -w '%{http_code}' --connect-timeout 3 --proxy-header "Proxy-Authorization: Basic $auth_b64" $progress $redirect $certificate -o "$1" "$url") result=$(curl $agent -w '%{http_code}' --connect-timeout 3 --proxy-header "Proxy-Authorization: Basic $auth_b64" $progress $redirect $certificate -o "$1" "$url")

View File

@@ -7,7 +7,10 @@ __IS_MODULE_2_SETTINGS_LOADED=1
settings() { #功能设置 settings() { #功能设置
#获取设置默认显示 #获取设置默认显示
[ -z "$skip_cert" ] && skip_cert=ON [ -z "$skip_cert" ] && skip_cert=ON
[ -z "$sniffer" ] && sniffer=OFF [ -z "$sniffer" ] && {
sniffer=OFF
echo "$crashcore" | grep -q 'singbox' && sniffer=ON
}
[ -z "$dns_mod" ] && dns_mod='redir_host' [ -z "$dns_mod" ] && dns_mod='redir_host'
# #
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -633,7 +636,7 @@ fw_filter_lan() { #局域网设备过滤
fi fi
###### ######
echo -e "\033[30;47m请在此添加或移除设备\033[0m" echo -e "\033[30;47m请在此添加或移除设备\033[0m"
echo -e "当前过滤方式为:\033[33m$fw_filter_lan_type模式\033[0m" echo -e "当前过滤方式为:\033[33m$macfilter_type模式\033[0m"
echo -e "仅列表内设备流量\033[36m$fw_filter_lan_scrip经过\033[0m内核" echo -e "仅列表内设备流量\033[36m$fw_filter_lan_scrip经过\033[0m内核"
if [ -n "$(cat "$CRASHDIR"/configs/mac)" ]; then if [ -n "$(cat "$CRASHDIR"/configs/mac)" ]; then
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -662,7 +665,7 @@ fw_filter_lan() { #局域网设备过滤
macfilter_type=$fw_filter_lan_over macfilter_type=$fw_filter_lan_over
setconfig macfilter_type $macfilter_type setconfig macfilter_type $macfilter_type
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[32m已切换为$fw_filter_lan_type模式\033[0m" echo -e "\033[32m已切换为$macfilter_type模式\033[0m"
fw_filter_lan fw_filter_lan
;; ;;
2) 2)

View File

@@ -108,9 +108,7 @@ task_add(){ #任务添加
} }
task_del(){ #任务删除 task_del(){ #任务删除
#删除定时任务 #删除定时任务
croncmd -l > "$TMPDIR"/cron cronset "$1"
sed -i "/$1/d" "$TMPDIR"/cron && croncmd "$TMPDIR"/cron
rm -f "$TMPDIR"/cron
#删除条件任务 #删除条件任务
sed -i "/$1/d" "$CRASHDIR"/task/cron 2>/dev/null sed -i "/$1/d" "$CRASHDIR"/task/cron 2>/dev/null
sed -i "/$1/d" "$CRASHDIR"/task/bfstart 2>/dev/null sed -i "/$1/d" "$CRASHDIR"/task/bfstart 2>/dev/null
@@ -214,7 +212,7 @@ task_type(){ #任务条件选择菜单
task_manager(){ #任务管理列表 task_manager(){ #任务管理列表
echo "-----------------------------------------------" echo "-----------------------------------------------"
#抽取并生成临时列表 #抽取并生成临时列表
croncmd -l > "$TMPDIR"/task_cronlist cronload > "$TMPDIR"/task_cronlist
cat "$TMPDIR"/task_cronlist "$CRASHDIR"/task/running 2>/dev/null | sort -u | grep -oE "task/task.sh .*" | awk -F ' ' '{print $2" "$3}' > "$TMPDIR"/task_list cat "$TMPDIR"/task_cronlist "$CRASHDIR"/task/running 2>/dev/null | sort -u | grep -oE "task/task.sh .*" | awk -F ' ' '{print $2" "$3}' > "$TMPDIR"/task_list
cat "$CRASHDIR"/task/bfstart "$CRASHDIR"/task/afstart "$CRASHDIR"/task/affirewall 2>/dev/null | awk -F ' ' '{print $2" "$3}' >> "$TMPDIR"/task_list cat "$CRASHDIR"/task/bfstart "$CRASHDIR"/task/afstart "$CRASHDIR"/task/affirewall 2>/dev/null | awk -F ' ' '{print $2" "$3}' >> "$TMPDIR"/task_list
cat "$TMPDIR"/task_cronlist 2>/dev/null | sort -u | grep -oE " #.*" | grep -v "守护" | awk -F '#' '{print "0 旧版任务-"$2}' >> "$TMPDIR"/task_list cat "$TMPDIR"/task_cronlist 2>/dev/null | sort -u | grep -oE " #.*" | grep -v "守护" | awk -F '#' '{print "0 旧版任务-"$2}' >> "$TMPDIR"/task_list
@@ -254,9 +252,8 @@ task_manager(){ #任务管理列表
read -p "旧版任务不支持管理,是否移除?(1/0) > " res read -p "旧版任务不支持管理,是否移除?(1/0) > " res
[ "$res" = 1 ] && { [ "$res" = 1 ] && {
cronname=$(echo $task_txt | awk -F '-' '{print $2}') cronname=$(echo $task_txt | awk -F '-' '{print $2}')
croncmd -l > $TMPDIR/conf && sed -i "/$cronname/d" $TMPDIR/conf && croncmd $TMPDIR/conf cronset "$cronname"
sed -i "/$cronname/d" $clashdir/tools/cron 2>/dev/null sed -i "/$cronname/d" "$CRASHDIR"/task/cron 2>/dev/null
rm -f $TMPDIR/conf
} }
else else
task_des=$(echo $task_txt | awk '{print $2}') task_des=$(echo $task_txt | awk '{print $2}')

View File

@@ -2,6 +2,7 @@
[ -z "$CRASHDIR" ] && CRASHDIR=$( cd $(dirname $0);cd ..;pwd) [ -z "$CRASHDIR" ] && CRASHDIR=$( cd $(dirname $0);cd ..;pwd)
. "$CRASHDIR"/libs/web_json.sh . "$CRASHDIR"/libs/web_json.sh
. "$CRASHDIR"/libs/set_config.sh
. "$CRASHDIR"/libs/web_get_lite.sh . "$CRASHDIR"/libs/web_get_lite.sh
. "$CRASHDIR"/menus/running_status.sh . "$CRASHDIR"/menus/running_status.sh
. "$CRASHDIR"/configs/gateway.cfg . "$CRASHDIR"/configs/gateway.cfg
@@ -308,6 +309,9 @@ polling(){
/crash) /crash)
send_menu send_menu
;; ;;
/"$my_alias")
send_menu
;;
/help) /help)
send_help send_help
;; ;;

View File

@@ -2,18 +2,16 @@
. "$CRASHDIR"/libs/set_cron.sh . "$CRASHDIR"/libs/set_cron.sh
bot_tg_start(){ bot_tg_start(){
bot_tg_stop
. "$CRASHDIR"/starts/start_legacy.sh . "$CRASHDIR"/starts/start_legacy.sh
start_legacy "$CRASHDIR/menus/bot_tg.sh" 'bot_tg' start_legacy "$CRASHDIR/menus/bot_tg.sh" 'bot_tg'
bot_tg_cron bot_tg_cron
} }
bot_tg_stop(){ bot_tg_stop(){
cronset 'TG_BOT守护进程' cronset 'TG_BOT守护进程'
[ -f "$TMPDIR/bot_tg.pid" ] && kill -TERM "$(cat "$TMPDIR/bot_tg.pid")" [ -f "$TMPDIR/bot_tg.pid" ] && kill -TERM "$(cat "$TMPDIR/bot_tg.pid")" 2>/dev/null
killall bot_tg.sh 2>/dev/null killall bot_tg.sh 2>/dev/null
rm -f "$TMPDIR/bot_tg.pid" rm -f "$TMPDIR/bot_tg.pid"
} }
bot_tg_cron(){ bot_tg_cron(){
cronset 'TG_BOT守护进程'
cronset 'TG_BOT守护进程' "* * * * * /bin/sh $CRASHDIR/starts/start_legacy_wd.sh bot_tg #ShellCrash-TG_BOT守护进程" cronset 'TG_BOT守护进程' "* * * * * /bin/sh $CRASHDIR/starts/start_legacy_wd.sh bot_tg #ShellCrash-TG_BOT守护进程"
} }

View File

@@ -14,7 +14,11 @@ task_logger(){
[ "$task_push" = 1 ] && push= || push=off [ "$task_push" = 1 ] && push= || push=off
[ -n "$2" -a "$2" != 0 ] && echo -e "\033[$2m$1\033[0m" [ -n "$2" -a "$2" != 0 ] && echo -e "\033[$2m$1\033[0m"
[ "$3" = 'off' ] && push=off [ "$3" = 'off' ] && push=off
echo "$1" |grep -qE '(每隔|时每)([1-9]|[1-9][0-9])分钟' || logger "$1" 0 "$push" echo "$1" |grep -qE '(每隔|时每)([1-9]|[1-9][0-9])分钟' && {
push=off
cover=on
}
logger "$1" 0 "$push" "$cover"
} }
#任务命令 #任务命令
@@ -31,7 +35,7 @@ update_core(){ #自动更新内核
task_logger "任务【自动更新内核】中止-未检测到版本更新" task_logger "任务【自动更新内核】中止-未检测到版本更新"
return 0 return 0
else else
. "$CRASHDIR"/libs/core_webget.sh && core_webget #调用下载工具 . "$CRASHDIR"/libs/core_tools.sh && core_webget #调用下载工具
case "$?" in case "$?" in
0) 0)
task_logger "任务【自动更新内核】下载完成,正在重启服务!" task_logger "任务【自动更新内核】下载完成,正在重启服务!"
@@ -57,18 +61,18 @@ update_scripts(){ #自动更新脚本
task_logger "任务【自动更新脚本】中止-未检测到版本更新" task_logger "任务【自动更新脚本】中止-未检测到版本更新"
return 0 return 0
else else
get_bin "$TMPDIR"/clashfm.tar.gz "bin/update.tar.gz" get_bin "$TMPDIR"/ShellCrash.tar.gz "ShellCrash.tar.gz"
if [ "$?" != "0" ];then if [ "$?" != "0" ];then
rm -rf "$TMPDIR"/clashfm.tar.gz rm -rf "$TMPDIR"/ShellCrash.tar.gz
task_logger "任务【自动更新内核】出错-下载失败!" task_logger "任务【自动更新内核】出错-下载失败!"
return 1 return 1
else else
#停止服务 #停止服务
"$CRASHDIR"/start.sh stop "$CRASHDIR"/start.sh stop
#解压 #解压
tar -zxf "$TMPDIR"/clashfm.tar.gz ${tar_para} -C "$CRASHDIR"/ tar -zxf "$TMPDIR"/ShellCrash.tar.gz ${tar_para} -C "$CRASHDIR"/
if [ $? -ne 0 ];then if [ $? -ne 0 ];then
rm -rf "$TMPDIR"/clashfm.tar.gz rm -rf "$TMPDIR"/ShellCrash.tar.gz
task_logger "任务【自动更新内核】出错-解压失败!" task_logger "任务【自动更新内核】出错-解压失败!"
"$CRASHDIR"/start.sh start "$CRASHDIR"/start.sh start
return 1 return 1
@@ -115,7 +119,7 @@ reset_firewall(){ #重设透明路由防火墙
"$CRASHDIR"/start.sh afstart "$CRASHDIR"/start.sh afstart
} }
ntp(){ ntp(){
[ "$crashcore" != singbox ] && ckcmd ntpd && ntpd -n -q -p 203.107.6.88 >/dev/null 2>&1 || exit 0 ckcmd ntpd && ntpd -n -q -p 203.107.6.88 >/dev/null 2>&1 || exit 0
} }
web_save_auto(){ web_save_auto(){
. "$CRASHDIR"/libs/web_save.sh && web_save . "$CRASHDIR"/libs/web_save.sh && web_save

View File

@@ -71,9 +71,11 @@ stop)
cronset '保守模式守护进程' cronset '保守模式守护进程'
cronset '运行时每' cronset '运行时每'
cronset '流媒体预解析' cronset '流媒体预解析'
#停止tg_bot
. "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_stop
#多种方式结束进程 #多种方式结束进程
if [ -f "$TMPDIR/shellcrash.pid" ];then if [ -f "$TMPDIR/shellcrash.pid" ];then
kill -TERM "$(cat "$TMPDIR/shellcrash.pid")" kill -TERM "$(cat "$TMPDIR/shellcrash.pid")" 2>/dev/null
rm -f "$TMPDIR/shellcrash.pid" rm -f "$TMPDIR/shellcrash.pid"
stop_firewall stop_firewall
elif [ "$USER" = "root" ] && grep -q 'systemd' /proc/1/comm; then elif [ "$USER" = "root" ] && grep -q 'systemd' /proc/1/comm; then

View File

@@ -33,14 +33,12 @@ if [ -n "$test" -o -n "$(pidof CrashCore)" ]; then
sleep 5 sleep 5
logger ShellCrash服务已启动 logger ShellCrash服务已启动
} & } &
ckcmd mtd_storage.sh && mtd_storage.sh save >/dev/null 2>&1 & #Padavan保存/etc/storage ckcmd mtd_storage.sh && mtd_storage.sh save >/dev/null 2>&1 #Padavan保存/etc/storage
#加载定时任务 #加载定时任务
[ -s "$CRASHDIR"/task/cron ] && croncmd "$CRASHDIR"/task/cron [ -s "$CRASHDIR"/task/cron ] && cronadd "$CRASHDIR"/task/cron
[ -s "$CRASHDIR"/task/running ] && { [ -s "$CRASHDIR"/task/running ] && {
cronset '运行时每' cronset '运行时每'
while read line; do cronadd "$CRASHDIR"/task/running
cronset '2fjdi124dd12s' "$line"
done <"$CRASHDIR"/task/running
} }
[ "$start_old" = "ON" ] && cronset '保守模式守护进程' "* * * * * /bin/sh $CRASHDIR/starts/start_legacy_wd.sh shellcrash #ShellCrash保守模式守护进程" [ "$start_old" = "ON" ] && cronset '保守模式守护进程' "* * * * * /bin/sh $CRASHDIR/starts/start_legacy_wd.sh shellcrash #ShellCrash保守模式守护进程"
#加载条件任务 #加载条件任务
@@ -48,12 +46,11 @@ if [ -n "$test" -o -n "$(pidof CrashCore)" ]; then
[ -s "$CRASHDIR"/task/affirewall -a -s /etc/init.d/firewall -a ! -f /etc/init.d/firewall.bak ] && { [ -s "$CRASHDIR"/task/affirewall -a -s /etc/init.d/firewall -a ! -f /etc/init.d/firewall.bak ] && {
#注入防火墙 #注入防火墙
line=$(grep -En "fw.* restart" /etc/init.d/firewall | cut -d ":" -f 1) line=$(grep -En "fw.* restart" /etc/init.d/firewall | cut -d ":" -f 1)
sed -i.bak "${line}a\\. "$CRASHDIR"/task/affirewall" /etc/init.d/firewall sed -i.bak "${line}a\\. $CRASHDIR/task/affirewall" /etc/init.d/firewall
line=$(grep -En "fw.* start" /etc/init.d/firewall | cut -d ":" -f 1) line=$(grep -En "fw.* start" /etc/init.d/firewall | cut -d ":" -f 1)
sed -i "${line}a\\. $CRASHDIR/task/affirewall" /etc/init.d/firewall sed -i "${line}a\\. $CRASHDIR/task/affirewall" /etc/init.d/firewall
} & } &
exit 0 exit 0
else else
. "$CRASHDIR"/starts/start_error.sh . "$CRASHDIR"/starts/start_error.sh
"$CRASHDIR"/start.sh stop
fi fi

View File

@@ -65,7 +65,7 @@ get_core_config() { #下载内核配置文件
exit 1 exit 1
else else
retry=$((retry + 1)) retry=$((retry + 1))
logger "配置文件获取失败!" 31 logger "配置文件获取失败!" 31 off on
if [ "$retry" = 1 ]; then if [ "$retry" = 1 ]; then
echo -e "\033[32m尝试更新服务器列表并使用其他服务器获取配置\033[0m" echo -e "\033[32m尝试更新服务器列表并使用其他服务器获取配置\033[0m"
update_servers update_servers

View File

@@ -23,7 +23,7 @@ fi
#写入环境变量 #写入环境变量
set_profile "$profile" set_profile "$profile"
#启动进程或删除守护进程 #启动进程或删除守护进程
if [ -f "$CRASHDIR"/.dis_startup ];then if [ -f "$CRASHDIR"/.dis_startup ] || [ -f "$CRASHDIR"/.start_error ];then
cronset "保守模式守护进程" cronset "保守模式守护进程"
else else
"$CRASHDIR"/start.sh start "$CRASHDIR"/start.sh start

View File

@@ -200,7 +200,7 @@ EOF
EOF EOF
#生成add_route.json #生成add_route.json
#域名嗅探配置 #域名嗅探配置
[ "$sniffer" = ON ] && sniffer_set='{ "action": "sniff", "timeout": "500ms" },' [ "$sniffer" != OFF ] && sniffer_set='{ "action": "sniff", "timeout": "500ms" },'
[ "$ts_service" = ON ] && tailscale_set='{ "inbound": [ "ts-ep" ], "port": 53, "action": "hijack-dns" },' [ "$ts_service" = ON ] && tailscale_set='{ "inbound": [ "ts-ep" ], "port": 53, "action": "hijack-dns" },'
cat >"$TMPDIR"/jsons/add_route.json <<EOF cat >"$TMPDIR"/jsons/add_route.json <<EOF
{ {

View File

@@ -2,6 +2,10 @@
# Copyright (C) Juewuy # Copyright (C) Juewuy
CRASHDIR="$(uci get firewall.ShellCrash.path | sed 's/\/starts.*//')" CRASHDIR="$(uci get firewall.ShellCrash.path | sed 's/\/starts.*//')"
#防止提前自启
/etc/init.d/shellcrash disable
crontab -l | grep -v 'start_legacy_wd.sh shellcrash' | crontab -
#防止usb未加载
i=0 i=0
while [ ! -f "$CRASHDIR/configs/ShellCrash.cfg" ]; do while [ ! -f "$CRASHDIR/configs/ShellCrash.cfg" ]; do
[ $i -gt 20 ] && exit 1 [ $i -gt 20 ] && exit 1
@@ -62,13 +66,16 @@ auto_start(){
chmod 755 /etc/init.d/shellcrash chmod 755 /etc/init.d/shellcrash
} }
#初始化环境变量 #初始化环境变量
grep -q '^export CRASHDIR=' '/etc/profile' && . "$CRASHDIR"/libs/set_profile.sh && set_profile '/etc/profile' grep -q '^export CRASHDIR=' '/etc/profile' || {
. "$CRASHDIR"/libs/set_profile.sh
set_profile '/etc/profile'
}
#启动服务 #启动服务
if [ ! -f "$CRASHDIR"/.dis_startup ]; then if [ ! -f "$CRASHDIR"/.dis_startup ] && [ ! -f "$CRASHDIR"/.start_error ]; then
#AX6S/AX6000修复tun功能 #AX6S/AX6000修复tun功能
[ -s "$CRASHDIR"/tools/tun.ko ] && tunfix [ -s "$CRASHDIR"/tools/tun.ko ] && tunfix
#小米7000/小米万兆修复tproxy #小米7000/小米万兆修复tproxy
[ -f /etc/init.d/qca-nss-ecm ] && [ "$redir_mod" = 'Tproxy' ] && tproxyfix [ -f /etc/init.d/qca-nss-ecm ] && echo "$redir_mod" | grep -q 'Tproxy' && tproxyfix
#自动覆盖根证书文件 #自动覆盖根证书文件
[ -s "$CRASHDIR"/tools/ca-certificates.crt ] && cp -f "$CRASHDIR"/tools/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt [ -s "$CRASHDIR"/tools/ca-certificates.crt ] && cp -f "$CRASHDIR"/tools/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
#启动服务 #启动服务

View File

@@ -11,3 +11,4 @@ touch "$CRASHDIR"/.start_error #标记启动失败,防止自启
error=$(cat "$TMPDIR"/core_test.log | grep -iEo 'error.*=.*|.*ERROR.*|.*FATAL.*') error=$(cat "$TMPDIR"/core_test.log | grep -iEo 'error.*=.*|.*ERROR.*|.*FATAL.*')
logger "服务启动失败!请查看报错信息!详细信息请查看$TMPDIR/core_test.log" 33 logger "服务启动失败!请查看报错信息!详细信息请查看$TMPDIR/core_test.log" 33
logger "$error" 31 logger "$error" 31
"$CRASHDIR"/start.sh stop

View File

@@ -4,7 +4,7 @@ PIDFILE="/tmp/ShellCrash/$1.pid"
if [ -f "$PIDFILE" ]; then if [ -f "$PIDFILE" ]; then
PID="$(cat "$PIDFILE")" PID="$(cat "$PIDFILE")"
if [ -n "$PID" ] && kill -0 "$PID" 2>/dev/null; then if [ -n "$PID" ] && [ -d "/proc/$PID" ]; then
return 0 return 0
fi fi
fi fi

View File

@@ -1 +1 @@
1.9.4rc1.1 1.9.4rc4