~修复首次创建自定义任务时的意外报错
~调整条件任务-启动前执行的执行顺位
~修复旧版本升级时创建用户的报错
~修复保守模式部分极端情况下开机自启的相关问题
This commit is contained in:
juewuy
2024-01-26 15:30:07 +08:00
parent b1358563ee
commit 395833f329
7 changed files with 14 additions and 10 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -5,4 +5,4 @@ meta_v=v1.18.0
singbox_v=1.7.8
GeoIP_v=20240120
versionsh=1.8.8f
versionsh=1.8.8g

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# Copyright (C) Juewuy
version=1.8.8f
version=1.8.8g
setdir(){
dir_avail(){
@@ -160,13 +160,13 @@ else
[ -w /etc/systemd/system ] && sysdir=/etc/systemd/system
if [ -n "$sysdir" -a "$USER" = "root" -a "$(cat /proc/1/comm)" = "systemd" ];then
#创建shellcrash用户并赋予root权限
sed -i '/0:7890/d' /etc/passwd
if type userdel useradd groupmod; then
userdel shellcrash 2>/dev/null
useradd shellcrash -u 7890 2>/dev/null
groupmod shellcrash -g 7890
groupmod shellcrash -g 7890 2>/dev/null
sed -Ei s/7890:7890/0:7890/g /etc/passwd
else
sed -i '/0:7890/d' /etc/passwd
echo "shellcrash:x:0:7890::/home/shellcrash:/bin/sh" >> /etc/passwd
fi
#配置systemd

View File

@@ -1512,6 +1512,8 @@ bfstart(){ #启动前
[ -z "$update_url" ] && update_url=https://fastly.jsdelivr.net/gh/juewuy/ShellCrash@master
[ ! -d ${BINDIR}/ui ] && mkdir -p ${BINDIR}/ui
[ -z "$crashcore" ] && crashcore=clash
#执行条件任务
[ -s ${CRASHDIR}/task/bfstart ] && source ${CRASHDIR}/task/bfstart
#检查内核配置文件
if [ ! -f $core_config ];then
if [ -n "$Url" -o -n "$Https" ];then
@@ -1555,8 +1557,6 @@ bfstart(){ #启动前
fi
#清理debug日志
rm -rf ${TMPDIR}/debug.log
#执行条件任务
[ -s ${CRASHDIR}/task/bfstart ] && source ${CRASHDIR}/task/bfstart
return 0
}
afstart(){ #启动后
@@ -1649,7 +1649,7 @@ start_old(){ #保守模式
$nohup $COMMAND &>/dev/null &
fi
afstart
cronset '保守模式守护进程' "* * * * * test -z \"\$(pidof CrashCore)\" && ${CRASHDIR}/start.sh start #ShellCrash保守模式守护进程"
cronset '保守模式守护进程' "* * * * * test -z \"\$(pidof CrashCore)\" && ${CRASHDIR}/start.sh daemon #ShellCrash保守模式守护进程"
}
#杂项
update_config(){ #更新订阅并重启
@@ -1723,6 +1723,10 @@ restart)
$0 stop
$0 start
;;
daemon)
[ ! -f $TMPDIR/crash_start_time ] && sleep 20
$0 start
;;
debug)
[ -n "$(pidof CrashCore)" ] && $0 stop >/dev/null #禁止多实例
getconfig

View File

@@ -198,7 +198,7 @@ task_user_add(){ #自定义命令添加
task_command=$script
echo -e "请检查输入:\033[32m$task_command\033[0m"
#获取本任务ID
task_max_id=$(awk -F'#' '{print $1}' ${CRASHDIR}/task/task.user | sort -n | tail -n 1)
task_max_id=$(awk -F '#' '{print $1}' ${CRASHDIR}/task/task.user 2>/dev/null | sort -n | tail -n 1)
[ -z "$task_max_id" ] && task_max_id=200
task_id=$((task_max_id + 1))
read -p "请输入任务备注 > " txt
@@ -233,8 +233,6 @@ task_add(){ #任务添加
echo -----------------------------------------------
echo -e "\033[36m请选择需要添加的任务\033[0m"
echo -----------------------------------------------
#检测并创建自定义任务文件
[ -f ${CRASHDIR}/task/task.user ] || echo '#任务ID(必须>200并顺序排列)#任务命令#任务说明(#号隔开,任务命令和说明中都不允许包含#号)' > ${CRASHDIR}/task/task.user
#输出任务列表
cat ${CRASHDIR}/task/task.list ${CRASHDIR}/task/task.user 2>/dev/null | grep -Ev '^(#|$)' | awk -F '#' '{print " "NR" "$3}'
echo -----------------------------------------------
@@ -468,6 +466,8 @@ task_recom(){ #任务推荐
}
}
task_menu(){ #任务菜单
#检测并创建自定义任务文件
[ -f ${CRASHDIR}/task/task.user ] || echo '#任务ID(必须>200并顺序排列)#任务命令#任务说明(#号隔开,任务命令和说明中都不允许包含#号)' > ${CRASHDIR}/task/task.user
echo -----------------------------------------------
echo -e "\033[30;47m欢迎使用自动任务功能\033[0m"
echo -----------------------------------------------