v1.4.1-test
~适配部分没有crontab的梅林设备
This commit is contained in:
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
clash_v=1.6.0
|
clash_v=1.6.0
|
||||||
clashpre_v=2021.05.08
|
clashpre_v=2021.05.08
|
||||||
versionsh=1.4.0
|
|
||||||
GeoIP_v=20210623
|
GeoIP_v=20210623
|
||||||
|
versionsh=1.4.1-test
|
||||||
|
|||||||
@@ -1053,7 +1053,19 @@ tools(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
clashcron(){
|
clashcron(){
|
||||||
|
croncmd(){
|
||||||
|
if [ -n "$(crontab -h 2>&1 | grep '\-l')" ];then
|
||||||
|
crontab $1
|
||||||
|
else
|
||||||
|
crondir="$(crond -h 2>&1 | grep -oE 'Default:.*' | awk -F ":" '{print $2}')"
|
||||||
|
[ ! -w "$crondir" ] && crondir="/etc/storage/cron/crontabs"
|
||||||
|
[ ! -w "$crondir" ] && crondir="/var/spool/cron/crontabs"
|
||||||
|
[ ! -w "$crondir" ] && crondir="/var/spool/cron"
|
||||||
|
[ ! -w "$crondir" ] && echo "你的设备不支持定时任务配置,脚本大量功能无法启用,请前往 https://t.me/clashfm 申请适配!"
|
||||||
|
[ "$1" = "-l" ] && cat $crondir/$USER 2>/dev/null
|
||||||
|
[ -f "$1" ] && cat $1 > $crondir/$USER
|
||||||
|
fi
|
||||||
|
}
|
||||||
setcron(){
|
setcron(){
|
||||||
setcrontab(){
|
setcrontab(){
|
||||||
#设置具体时间
|
#设置具体时间
|
||||||
@@ -1082,13 +1094,14 @@ clashcron(){
|
|||||||
read -p "是否确认添加定时任务?(1/0) > " res
|
read -p "是否确认添加定时任务?(1/0) > " res
|
||||||
if [ "$res" = '1' ]; then
|
if [ "$res" = '1' ]; then
|
||||||
cronwords="$min $hour * * $week $cronset >/dev/null 2>&1 #$week1的$hour点$min分$cronname"
|
cronwords="$min $hour * * $week $cronset >/dev/null 2>&1 #$week1的$hour点$min分$cronname"
|
||||||
crondir=/tmp/cron_$USER
|
tmpcron=/tmp/cron_$USER
|
||||||
crontab -l > $crondir
|
croncmd -l > $tmpcron
|
||||||
sed -i "/$cronname/d" $crondir
|
sed -i "/$cronname/d" $tmpcron
|
||||||
sed -i '/^$/d' $crondir
|
sed -i '/^$/d' $tmpcron
|
||||||
echo "$cronwords" >> $crondir && crontab $crondir
|
echo "$cronwords" >> $tmpcron
|
||||||
|
croncmd $tmpcron
|
||||||
#华硕/Padavan固件存档在本地,其他则删除
|
#华硕/Padavan固件存档在本地,其他则删除
|
||||||
[ "$clashdir" = "/jffs/clash" -o "$clashdir" = "/etc/storage/clash" ] && mv -f $crondir $clashdir/cron || rm -f $crondir
|
[ "$clashdir" = "/jffs/clash" -o "$clashdir" = "/etc/storage/clash" ] && mv -f $tmpcron $clashdir/cron || rm -f $tmpcron
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[31m定时任务已添加!!!\033[0m"
|
echo -e "\033[31m定时任务已添加!!!\033[0m"
|
||||||
fi
|
fi
|
||||||
@@ -1111,8 +1124,8 @@ clashcron(){
|
|||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
i=
|
i=
|
||||||
elif [ "$num" = 9 ]; then
|
elif [ "$num" = 9 ]; then
|
||||||
crontab -l > /tmp/conf && sed -i "/$cronname/d" /tmp/conf && crontab /tmp/conf
|
croncmd -l > /tmp/conf && sed -i "/$cronname/d" /tmp/conf && croncmd /tmp/conf
|
||||||
sed -i "/$cronname/d" $clashdir/cron
|
sed -i "/$cronname/d" $clashdir/cron 2>/dev/null
|
||||||
rm -f /tmp/conf
|
rm -f /tmp/conf
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[31m定时任务:$cronname已删除!\033[0m"
|
echo -e "\033[31m定时任务:$cronname已删除!\033[0m"
|
||||||
@@ -1134,7 +1147,7 @@ clashcron(){
|
|||||||
echo -e "\033[44m 实验性功能,遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
echo -e "\033[44m 实验性功能,遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[33m已添加的定时任务:\033[36m"
|
echo -e "\033[33m已添加的定时任务:\033[36m"
|
||||||
crontab -l | grep -oE ' #.*'
|
croncmd -l | grep -oE ' #.*'
|
||||||
echo -e "\033[0m"-----------------------------------------------
|
echo -e "\033[0m"-----------------------------------------------
|
||||||
echo -e " 1 设置\033[33m定时重启\033[0mclash服务"
|
echo -e " 1 设置\033[33m定时重启\033[0mclash服务"
|
||||||
echo -e " 2 设置\033[31m定时停止\033[0mclash服务"
|
echo -e " 2 设置\033[31m定时停止\033[0mclash服务"
|
||||||
|
|||||||
@@ -54,14 +54,25 @@ logger(){
|
|||||||
[ "$(wc -l $clashdir/log | awk '{print $1}')" -gt 30 ] && sed -i '1,5d' $clashdir/log
|
[ "$(wc -l $clashdir/log | awk '{print $1}')" -gt 30 ] && sed -i '1,5d' $clashdir/log
|
||||||
}
|
}
|
||||||
cronset(){
|
cronset(){
|
||||||
|
if [ -n "$(crontab -h 2>&1 | grep '\-l')" ];then
|
||||||
|
crontab $1
|
||||||
|
else
|
||||||
|
crondir="$(crond -h 2>&1 | grep -oE 'Default:.*' | awk -F ":" '{print $2}')"
|
||||||
|
[ ! -w "$crondir" ] && crondir="/etc/storage/cron/crontabs"
|
||||||
|
[ ! -w "$crondir" ] && crondir="/var/spool/cron/crontabs"
|
||||||
|
[ ! -w "$crondir" ] && crondir="/var/spool/cron"
|
||||||
|
[ ! -w "$crondir" ] && echo "你的设备不支持定时任务配置,脚本大量功能无法启用,请前往 https://t.me/clashfm 申请适配!"
|
||||||
|
[ "$1" = "-l" ] && cat $crondir/$USER 2>/dev/null
|
||||||
|
[ -f "$1" ] && cat $1 > $crondir/$USER
|
||||||
|
fi
|
||||||
# 参数1代表要移除的关键字,参数2代表要添加的任务语句
|
# 参数1代表要移除的关键字,参数2代表要添加的任务语句
|
||||||
crondir=/tmp/cron_$USER
|
tmpcron=/tmp/cron_$USER
|
||||||
crontab -l > $crondir 2>/dev/null
|
croncmd -l > $tmpcron
|
||||||
sed -i "/$1/d" $crondir
|
sed -i "/$1/d" $tmpcron
|
||||||
sed -i '/^$/d' $crondir
|
sed -i '/^$/d' $tmpcron
|
||||||
echo "$2" >> $crondir
|
echo "$2" >> $tmpcron
|
||||||
crontab $crondir
|
croncmd $tmpcron
|
||||||
rm -f $crondir
|
rm -f $tmpcron
|
||||||
}
|
}
|
||||||
mark_time(){
|
mark_time(){
|
||||||
start_time=`date +%s`
|
start_time=`date +%s`
|
||||||
|
|||||||
Reference in New Issue
Block a user