~增加了未安装面板时的跳转提示页面
~增加了日志一键清空的功能
~修复面板提示覆盖安装时,无法取消安装的bug
~修复安装或更新脚本时的报错提示
~修复任务无法一键清空的bug
~修复了部分任务未显示日志的bug
~修复了部分推荐任务执行间隔出错的bug
This commit is contained in:
juewuy
2024-01-04 12:36:54 +08:00
parent 61936e3c3f
commit 9f55974d1c
5 changed files with 109 additions and 75 deletions

View File

@@ -167,13 +167,7 @@ errornum(){
} }
startover(){ startover(){
echo -e "\033[32m服务已启动\033[0m" echo -e "\033[32m服务已启动\033[0m"
if [ -n "$hostdir" ];then echo -e "请使用 \033[4;32mhttp://$host$hostdir\033[0m 管理内置规则"
echo -e "请使用 \033[4;32mhttp://$host$hostdir\033[0m 管理内置规则"
else
echo -e "可使用 \033[4;32mhttp://clash.razord.top\033[0m 管理内置规则"
echo -e "Host地址:\033[36m $host \033[0m 端口:\033[36m $db_port \033[0m"
echo -e "推荐前往更新菜单安装本地Dashboard面板连接更稳定\033[0m"
fi
if [ "$redir_mod" = "纯净模式" ];then if [ "$redir_mod" = "纯净模式" ];then
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "其他设备可以使用PAC配置连接\033[4;32mhttp://$host:$db_port/ui/pac\033[0m" echo -e "其他设备可以使用PAC配置连接\033[4;32mhttp://$host:$db_port/ui/pac\033[0m"
@@ -200,7 +194,7 @@ checkrestart(){
[ "$res" = 1 ] && clashstart [ "$res" = 1 ] && clashstart
} }
#功能相关 #功能相关
log_pusher(){ log_pusher(){ #日志菜单
[ -n "$push_TG" ] && stat_TG=32m已启用 || stat_TG=33m未启用 [ -n "$push_TG" ] && stat_TG=32m已启用 || stat_TG=33m未启用
[ -n "$push_Deer" ] && stat_Deer=32m已启用 || stat_Deer=33m未启用 [ -n "$push_Deer" ] && stat_Deer=32m已启用 || stat_Deer=33m未启用
[ -n "$push_bark" ] && stat_bark=32m已启用 || stat_bark=33m未启用 [ -n "$push_bark" ] && stat_bark=32m已启用 || stat_bark=33m未启用
@@ -214,14 +208,20 @@ log_pusher(){
echo -e " 4 Bark推送-IOS ——\033[$stat_bark\033[0m" echo -e " 4 Bark推送-IOS ——\033[$stat_bark\033[0m"
echo -e " 5 Passover推送 ——\033[$stat_Po\033[0m" echo -e " 5 Passover推送 ——\033[$stat_Po\033[0m"
echo -e " 6 推送任务日志 ——\033[$task_push\033[0m" echo -e " 6 推送任务日志 ——\033[$task_push\033[0m"
echo -e " 9 设置设备名称 ——\033[$device_s\033[0m" echo -e " 8 设置设备名称 ——\033[$device_s\033[0m"
echo -e " 9 清空日志文件"
echo ----------------------------------------------- echo -----------------------------------------------
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case $num in case $num in
1) 1)
echo ----------------------------------------------- if [ -s $TMPDIR/ShellCrash.log ];then
cat $TMPDIR/ShellCrash.log echo -----------------------------------------------
exit cat $TMPDIR/ShellCrash.log
exit 0
else
echo -e "\033[31m未找到相关日志\033[0m"
fi
sleep 1
;; ;;
2) 2)
echo ----------------------------------------------- echo -----------------------------------------------
@@ -374,12 +374,18 @@ log_pusher(){
sleep 1 sleep 1
log_pusher log_pusher
;; ;;
9) 8)
read -p "请输入本设备自定义推送名称 > " device_name read -p "请输入本设备自定义推送名称 > " device_name
setconfig device_name $device_name setconfig device_name $device_name
sleep 1 sleep 1
log_pusher log_pusher
;; ;;
9)
echo -e "\033[33m运行日志及任务日志均已清空\033[0m"
rm -rf $TMPDIR/ShellCrash.log
sleep 1
log_pusher
;;
*) errornum ;; *) errornum ;;
esac esac
} }

View File

@@ -1019,7 +1019,7 @@ setgeo(){
getdb(){ getdb(){
#下载及安装 #下载及安装
if [ -f /www/clash/index.html -o -f $CRASHDIR/ui/index.html ];then if [ -f /www/clash/CNAME -o -f $CRASHDIR/ui/CNAME ];then
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "\033[31m检测到您已经安装过本地面板了\033[0m" echo -e "\033[31m检测到您已经安装过本地面板了\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
@@ -1028,41 +1028,43 @@ getdb(){
rm -rf /www/clash rm -rf /www/clash
rm -rf $CRASHDIR/ui rm -rf $CRASHDIR/ui
rm -rf $bindir/ui rm -rf $bindir/ui
fi dblink="${update_url}/bin/dashboard/${db_type}.tar.gz"
fi echo -----------------------------------------------
dblink="${update_url}/bin/dashboard/${db_type}.tar.gz" echo 正在连接服务器获取安装文件…………
echo ----------------------------------------------- $CRASHDIR/start.sh webget $TMPDIR/clashdb.tar.gz $dblink
echo 正在连接服务器获取安装文件………… if [ "$?" = "1" ];then
$CRASHDIR/start.sh webget $TMPDIR/clashdb.tar.gz $dblink echo -----------------------------------------------
if [ "$?" = "1" ];then echo -e "\033[31m文件下载失败\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "\033[31m文件下载失败\033[0m" error_down
echo ----------------------------------------------- setdb
error_down else
setdb echo -e "\033[33m下载成功正在解压文件\033[0m"
else mkdir -p $dbdir > /dev/null
echo -e "\033[33m下载成功正在解压文件\033[0m" tar -zxvf "$TMPDIR/clashdb.tar.gz" -C $dbdir > /dev/null
mkdir -p $dbdir > /dev/null if [ $? -ne 0 ];then
tar -zxvf "$TMPDIR/clashdb.tar.gz" -C $dbdir > /dev/null tar -zxvf "$TMPDIR/clashdb.tar.gz" --no-same-permissions -C $dbdir > /dev/null
if [ $? -ne 0 ];then [ $? -ne 0 ] && echo "文件解压失败!" && rm -rf $TMPDIR/clashfm.tar.gz && exit 1
tar -zxvf "$TMPDIR/clashdb.tar.gz" --no-same-permissions -C $dbdir > /dev/null fi
[ $? -ne 0 ] && echo "文件解压失败!" && rm -rf $TMPDIR/clashfm.tar.gz && exit 1 #修改默认host和端口
fi if [ "$db_type" = "clashdb" -o "$db_type" = "meta_db" -o "$db_type" = "meta_xd" ];then
#修改默认host和端口 sed -i "s/127.0.0.1/${host}/g" $dbdir/assets/*.js
if [ "$db_type" = "clashdb" -o "$db_type" = "meta_db" -o "$db_type" = "meta_xd" ];then sed -i "s/9090/${db_port}/g" $dbdir/assets/*.js
sed -i "s/127.0.0.1/${host}/g" $dbdir/assets/*.js else
sed -i "s/9090/${db_port}/g" $dbdir/assets/*.js sed -i "s/127.0.0.1:9090/${host}:${db_port}/g" $dbdir/*.html
#sed -i "s/7892/${db_port}/g" $dbdir/app*.js
fi
#写入配置文件
setconfig hostdir \'$hostdir\'
echo -----------------------------------------------
echo -e "\033[32m面板安装成功\033[0m"
rm -rf $TMPDIR/clashdb.tar.gz
fi
else else
sed -i "s/127.0.0.1:9090/${host}:${db_port}/g" $dbdir/*.html echo -e "\033[33m安装已取消\033[0m"
#sed -i "s/7892/${db_port}/g" $dbdir/app*.js
fi fi
#写入配置文件
setconfig hostdir \'$hostdir\'
echo -----------------------------------------------
echo -e "\033[32m面板安装成功\033[0m"
rm -rf $TMPDIR/clashdb.tar.gz
sleep 1
fi fi
sleep 1
} }
setdb(){ setdb(){
dbdir(){ dbdir(){

View File

@@ -213,8 +213,8 @@ fi
#镜像化OpenWrt(snapshot)额外设置 #镜像化OpenWrt(snapshot)额外设置
if [ "$systype" = "mi_snapshot" -o "$systype" = "ng_snapshot" ];then if [ "$systype" = "mi_snapshot" -o "$systype" = "ng_snapshot" ];then
chmod 755 $CRASHDIR/misnap_init.sh chmod 755 $CRASHDIR/misnap_init.sh
uci delete firewall.ShellClash uci delete firewall.ShellClash 2>/dev/null
uci delete firewall.ShellCrash uci delete firewall.ShellCrash 2>/dev/null
uci set firewall.ShellCrash=include uci set firewall.ShellCrash=include
uci set firewall.ShellCrash.type='script' uci set firewall.ShellCrash.type='script'
uci set firewall.ShellCrash.path="$CRASHDIR/misnap_init.sh" uci set firewall.ShellCrash.path="$CRASHDIR/misnap_init.sh"
@@ -258,8 +258,8 @@ for file in log clash.service mark? mark.bak;do
rm -rf $CRASHDIR/$file rm -rf $CRASHDIR/$file
done done
#旧版任务清理 #旧版任务清理
$CRASHDIR/start.sh cronset "clash服务" $CRASHDIR/start.sh cronset "clash服务" 2>/dev/null
$CRASHDIR/start.sh cronset "订阅链接" $CRASHDIR/start.sh cronset "订阅链接" 2>/dev/null
$CRASHDIR/start.sh cronset "ShellCrash初始化" $CRASHDIR/start.sh cronset "ShellCrash初始化" 2>/dev/null
sleep 1 sleep 1
echo -e "\033[32m脚本初始化完成,请输入\033[30;47m crash \033[0;33m命令开始使用\033[0m" echo -e "\033[32m脚本初始化完成,请输入\033[30;47m crash \033[0;33m命令开始使用\033[0m"

View File

@@ -58,7 +58,7 @@ logger(){
[ -n "$2" -a "$2" != 0 ] && echo -e "\033[$2m$1\033[0m" [ -n "$2" -a "$2" != 0 ] && echo -e "\033[$2m$1\033[0m"
log_text="$(date "+%G-%m-%d_%H:%M:%S")~$1" log_text="$(date "+%G-%m-%d_%H:%M:%S")~$1"
echo $log_text >> $TMPDIR/ShellCrash.log echo $log_text >> $TMPDIR/ShellCrash.log
[ "$(wc -l $TMPDIR/ShellCrash.log | awk '{print $1}')" -gt 99 ] && sed -i '1,5d' $TMPDIR/ShellCrash.log [ "$(wc -l $TMPDIR/ShellCrash.log | awk '{print $1}')" -gt 99 ] && sed -i '1,50d' $TMPDIR/ShellCrash.log
[ -z "$3" ] && { [ -z "$3" ] && {
getconfig getconfig
[ -n "$device_name" ] && log_text="$log_text($device_name)" [ -n "$device_name" ] && log_text="$log_text($device_name)"
@@ -1093,14 +1093,35 @@ web_restore(){
done done
} }
#启动相关 #启动相关
makehtml(){
cat > $bindir/ui/index.html <<EOF
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ShellCrash面板提示</title>
</head>
<body>
<div style="text-align: center; margin-top: 50px;">
<h1>您还未安装本地面板</h1>
<h3>请在脚本更新功能中(9-4)安装<br>或者使用在线面板:</h3>
<a href="https://metacubexd.pages.dev" style="font-size: 24px;">Meta XD面板(推荐)<br></a>
<a href="https://yacd.metacubex.one" style="font-size: 24px;">Meta YACD面板(推荐)<br></a>
<a href="https://yacd.haishan.me" style="font-size: 24px;">Clash YACD面板<br></a>
<a href="https://clash.razord.top" style="font-size: 24px;">Clash Razord面板<br></a>
<a style="font-size: 16px;"><br>如已安装请使用Ctrl+F5强制刷新<br></a>
</div>
</body>
</html
EOF
}
catpac(){ catpac(){
#获取本机host地址 #获取本机host地址
[ -n "$host" ] && host_pac=$host [ -n "$host" ] && host_pac=$host
[ -z "$host_pac" ] && host_pac=$(ubus call network.interface.lan status 2>&1 | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';) [ -z "$host_pac" ] && host_pac=$(ubus call network.interface.lan status 2>&1 | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';)
[ -z "$host_pac" ] && host_pac=$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep -E ' 1(92|0|72)\.' | sed 's/.*inet.//g' | sed 's/\/[0-9][0-9].*$//g' | head -n 1) [ -z "$host_pac" ] && host_pac=$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep -E ' 1(92|0|72)\.' | sed 's/.*inet.//g' | sed 's/\/[0-9][0-9].*$//g' | head -n 1)
cat > $TMPDIR/clash_pac <<EOF cat > $TMPDIR/clash_pac <<EOF
//如看见此处内容,请重新安装本地面板!
//之后返回上一级页面,清理浏览器缓存并刷新页面!
function FindProxyForURL(url, host) { function FindProxyForURL(url, host) {
if ( if (
isInNet(host, "0.0.0.0", "255.0.0.0")|| isInNet(host, "0.0.0.0", "255.0.0.0")||
@@ -1197,6 +1218,7 @@ bfstart(){
if [ -f $CRASHDIR/ui/index.html -a ! -f $bindir/ui/index.html ];then if [ -f $CRASHDIR/ui/index.html -a ! -f $bindir/ui/index.html ];then
cp -rf $CRASHDIR/ui $bindir cp -rf $CRASHDIR/ui $bindir
fi fi
[ ! -s $bindir/ui/index.html ] && makehtml #如没有面板则创建跳转界面
#检查curl或wget支持 #检查curl或wget支持
curl --version > /dev/null 2>&1 curl --version > /dev/null 2>&1
[ "$?" = 1 ] && wget --version > /dev/null 2>&1 [ "$?" = 1 ] && wget --version > /dev/null 2>&1

View File

@@ -28,13 +28,13 @@ update_core(){ #自动更新内核
clash_v_new=$(eval echo \$${clashcore}_v) clash_v_new=$(eval echo \$${clashcore}_v)
clash_v_now=$($bindir/clash -v 2>/dev/null | head -n 1 | sed 's/ linux.*//;s/.* //') clash_v_now=$($bindir/clash -v 2>/dev/null | head -n 1 | sed 's/ linux.*//;s/.* //')
if [ -z "$clash_v_new" -o "$clash_v_new" = "clash_v_now" ];then if [ -z "$clash_v_new" -o "$clash_v_new" = "clash_v_now" ];then
logger "任务:【自动更新内核】中止-未检测到版本更新" logger "任务【自动更新内核】中止-未检测到版本更新"
exit 1 exit 1
else else
#更新内核 #更新内核
$CRASHDIR/start.sh webget $TMPDIR/clash.new "$update_url/bin/$clashcore/clash-linux-$cpucore" $CRASHDIR/start.sh webget $TMPDIR/clash.new "$update_url/bin/$clashcore/clash-linux-$cpucore"
if [ "$?" != "0" ];then if [ "$?" != "0" ];then
logger "任务:【自动更新内核】出错-下载失败!" logger "任务【自动更新内核】出错-下载失败!"
rm -rf $TMPDIR/clash.new rm -rf $TMPDIR/clash.new
return 1 return 1
else else
@@ -42,13 +42,13 @@ update_core(){ #自动更新内核
$CRASHDIR/start.sh stop $CRASHDIR/start.sh stop
clashv=$($TMPDIR/clash.new -v 2>/dev/null | sed 's/ linux.*//;s/.* //') clashv=$($TMPDIR/clash.new -v 2>/dev/null | sed 's/ linux.*//;s/.* //')
if [ -z "$clashv" ];then if [ -z "$clashv" ];then
logger "任务:【自动更新内核】出错-下载失败!" logger "任务【自动更新内核】出错-下载失败!"
rm -rf $TMPDIR/clash.new rm -rf $TMPDIR/clash.new
[ $clashcore = meta ] && $CRASHDIR/start.sh start [ $clashcore = meta ] && $CRASHDIR/start.sh start
return 1 return 1
else else
mv -f $TMPDIR/clash.new $bindir/clash mv -f $TMPDIR/clash.new $bindir/clash
logger "任务:【自动更新内核】下载完成,正在重启服务!" logger "任务【自动更新内核】下载完成,正在重启服务!"
$CRASHDIR/start.sh start $CRASHDIR/start.sh start
return 0 return 0
fi fi
@@ -59,20 +59,20 @@ update_shellclash(){ #自动更新脚本
#检查版本 #检查版本
check_update check_update
if [ -z "$versionsh" -o "$versionsh" = "versionsh_l" ];then if [ -z "$versionsh" -o "$versionsh" = "versionsh_l" ];then
logger "任务:【自动更新脚本】中止-未检测到版本更新" logger "任务【自动更新脚本】中止-未检测到版本更新"
exit 1 exit 1
else else
$CRASHDIR/start.sh webget $TMPDIR/clashfm.tar.gz "$update_url/bin/clashfm.tar.gz" $CRASHDIR/start.sh webget $TMPDIR/clashfm.tar.gz "$update_url/bin/clashfm.tar.gz"
if [ "$?" != "0" ];then if [ "$?" != "0" ];then
rm -rf $TMPDIR/clashfm.tar.gz rm -rf $TMPDIR/clashfm.tar.gz
logger "任务:【自动更新内核】出错-下载失败!" logger "任务【自动更新内核】出错-下载失败!"
return 1 return 1
else else
#解压 #解压
tar -zxvf "$TMPDIR/clashfm.tar.gz" -C $CRASHDIR/ || tar -zxvf "$TMPDIR/clashfm.tar.gz" --no-same-owner -C $CRASHDIR/ tar -zxvf "$TMPDIR/clashfm.tar.gz" -C $CRASHDIR/ || tar -zxvf "$TMPDIR/clashfm.tar.gz" --no-same-owner -C $CRASHDIR/
if [ $? -ne 0 ];then if [ $? -ne 0 ];then
rm -rf $TMPDIR/clashfm.tar.gz rm -rf $TMPDIR/clashfm.tar.gz
logger "任务:【自动更新内核】出错-解压失败!" logger "任务【自动更新内核】出错-解压失败!"
return 1 return 1
else else
source $CRASHDIR/init.sh >/dev/null source $CRASHDIR/init.sh >/dev/null
@@ -89,18 +89,18 @@ update_mmdb(){ #自动更新数据库
geo_v_new=$GeoIP_v geo_v_new=$GeoIP_v
geo_v_now=$(eval echo \$$geo_v) geo_v_now=$(eval echo \$$geo_v)
if [ -z "$geo_v_new" -o "$geo_v_new" = "$geo_v_now" ];then if [ -z "$geo_v_new" -o "$geo_v_new" = "$geo_v_now" ];then
logger "任务:【自动更新数据库文件】跳过-未检测到$2版本更新" logger "任务【自动更新数据库文件】跳过-未检测到$2版本更新"
else else
#更新文件 #更新文件
$CRASHDIR/start.sh webget $TMPDIR/$1 "$update_url/bin/geodata/$2" $CRASHDIR/start.sh webget $TMPDIR/$1 "$update_url/bin/geodata/$2"
if [ "$?" != "0" ];then if [ "$?" != "0" ];then
logger "任务:【自动更新数据库文件】更新【$2】下载失败!" logger "任务【自动更新数据库文件】更新【$2】下载失败!"
rm -rf $TMPDIR/$1 rm -rf $TMPDIR/$1
return 1 return 1
else else
mv -f $TMPDIR/$1 $bindir/$1 mv -f $TMPDIR/$1 $bindir/$1
setconfig $geo_v $GeoIP_v setconfig $geo_v $GeoIP_v
logger "任务:【自动更新数据库文件】更新【$2】成功!" logger "任务【自动更新数据库文件】更新【$2】成功!"
return 0 return 0
fi fi
fi fi
@@ -144,7 +144,6 @@ cronset(){
sed -i '/^$/d' $tmpcron sed -i '/^$/d' $tmpcron
echo "$2" >> $tmpcron echo "$2" >> $tmpcron
croncmd $tmpcron croncmd $tmpcron
rm -f $tmpcron
#华硕/Padavan固件存档在本地,其他则删除 #华硕/Padavan固件存档在本地,其他则删除
[ "$CRASHDIR" = "/jffs/clash" -o "$CRASHDIR" = "/etc/storage/clash" ] && mv -f $tmpcron $CRASHDIR/task/cron || rm -f $tmpcron [ "$CRASHDIR" = "/jffs/clash" -o "$CRASHDIR" = "/etc/storage/clash" ] && mv -f $tmpcron $CRASHDIR/task/cron || rm -f $tmpcron
} }
@@ -160,7 +159,7 @@ set_cron(){
cronset "$cron_time$task_name" "$task_txt" cronset "$cron_time$task_name" "$task_txt"
fi fi
unset week hour min unset week hour min
echo -e "任务:$cron_time$task_name】\033[32m添加成功\033[0m" echo -e "任务【$cron_time$task_name】\033[32m添加成功\033[0m"
sleep 1 sleep 1
} }
set_service(){ set_service(){
@@ -174,7 +173,7 @@ set_service(){
else else
echo "$CRASHDIR/task/task.sh $2 $3" >> $task_file echo "$CRASHDIR/task/task.sh $2 $3" >> $task_file
fi fi
echo -e "任务:$3】\033[32m添加成功\033[0m" echo -e "任务【$3】\033[32m添加成功\033[0m"
sleep 1 sleep 1
} }
#任务界面 #任务界面
@@ -249,9 +248,9 @@ task_add(){ #任务添加
task_del(){ #任务删除 task_del(){ #任务删除
#删除定时任务 #删除定时任务
croncmd -l > $TMPDIR/cron && sed -i "/$1/d" $TMPDIR/cron && croncmd $TMPDIR/cron croncmd -l > $TMPDIR/cron && sed -i "/$1/d" $TMPDIR/cron && croncmd $TMPDIR/cron
sed -i "/$1/d" $CRASHDIR/task/cron 2>/dev/null
rm -f $TMPDIR/cron rm -f $TMPDIR/cron
#删除条件任务 #删除条件任务
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
sed -i "/$1/d" $CRASHDIR/task/afstart 2>/dev/null sed -i "/$1/d" $CRASHDIR/task/afstart 2>/dev/null
sed -i "/$1/d" $CRASHDIR/task/running 2>/dev/null sed -i "/$1/d" $CRASHDIR/task/running 2>/dev/null
@@ -359,7 +358,7 @@ task_manager(){ #任务管理列表
0) 0)
;; ;;
d) d)
task_del "$CRASHDIR\/task\/task.sh" task_del "task.sh"
echo -e "\033[31m全部任务已清空\033[36m" echo -e "\033[31m全部任务已清空\033[36m"
sleep 1 sleep 1
;; ;;
@@ -390,7 +389,7 @@ task_manager(){ #任务管理列表
3) 3)
task_command=$(cat $CRASHDIR/task/task.list $CRASHDIR/task/task.user 2>/dev/null | grep "$task_id" | awk -F '#' '{print $2}') task_command=$(cat $CRASHDIR/task/task.list $CRASHDIR/task/task.user 2>/dev/null | grep "$task_id" | awk -F '#' '{print $2}')
eval $task_command && task_res='执行成功!' || task_res='执行失败!' eval $task_command && task_res='执行成功!' || task_res='执行失败!'
logger "任务:$task_des$task_res" 33 off logger "任务【$task_des$task_res" 33 off
sleep 1 sleep 1
;; ;;
4) 4)
@@ -425,10 +424,10 @@ task_recom(){ #任务推荐
echo ----------------------------------------------- echo -----------------------------------------------
read -p "是否启用?(1/0) > " res read -p "是否启用?(1/0) > " res
[ "$res" = 1 ] && { [ "$res" = 1 ] && {
set_service running "106" "运行时每10分钟自动保存面板配置" "1/10" set_service running "106" "运行时每10分钟自动保存面板配置" "*/10"
set_service afstart "107" "服务启动后自动同步ntp时间" set_service afstart "107" "服务启动后自动同步ntp时间"
cronset "在每周3的3点整更新订阅并重启服务" "0 3 * * 3 $CRASHDIR/task/task.sh 104 在每周3的3点整更新订阅并重启服务" && \ cronset "在每周3的3点整更新订阅并重启服务" "0 3 * * 3 $CRASHDIR/task/task.sh 104 在每周3的3点整更新订阅并重启服务" && \
echo -e "任务:【在每周3的3点整更新订阅并重启服务】\033[32m添加成功\033[0m" echo -e "任务【在每周3的3点整更新订阅并重启服务】\033[32m添加成功\033[0m"
} }
} }
task_menu(){ #任务菜单 task_menu(){ #任务菜单
@@ -458,8 +457,13 @@ task_menu(){ #任务菜单
task_menu task_menu
;; ;;
3) 3)
echo ----------------------------------------------- if [ -n "$(cat $TMPDIR/ShellCrash.log | grep '任务【')" ];then
cat $TMPDIR/ShellCrash.log | grep '任务:' echo -----------------------------------------------
cat $TMPDIR/ShellCrash.log | grep '任务【'
else
echo -e "\033[31m未找到任务相关执行日志\033[0m"
fi
sleep 1
task_menu task_menu
;; ;;
4) 4)
@@ -495,7 +499,7 @@ case "$1" in
[1-9][0-9][0-9]) [1-9][0-9][0-9])
task_command=$(cat $CRASHDIR/task/task.list $CRASHDIR/task/task.user 2>/dev/null | grep "$1" | awk -F '#' '{print $2}') task_command=$(cat $CRASHDIR/task/task.list $CRASHDIR/task/task.user 2>/dev/null | grep "$1" | awk -F '#' '{print $2}')
task_name=$(cat $CRASHDIR/task/task.list $CRASHDIR/task/task.user 2>/dev/null | grep "$1" | awk -F '#' '{print $3}') task_name=$(cat $CRASHDIR/task/task.list $CRASHDIR/task/task.user 2>/dev/null | grep "$1" | awk -F '#' '{print $3}')
#logger "任务:$task_name 开始执行" #logger "任务$task_name 开始执行"
eval $task_command && task_res=成功 || task_res=失败 eval $task_command && task_res=成功 || task_res=失败
logger "任务【$2】执行$task_res" logger "任务【$2】执行$task_res"
;; ;;