v1.4.1-test
~适配部分没有crontab的梅林设备
This commit is contained in:
@@ -54,14 +54,25 @@ logger(){
|
||||
[ "$(wc -l $clashdir/log | awk '{print $1}')" -gt 30 ] && sed -i '1,5d' $clashdir/log
|
||||
}
|
||||
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代表要添加的任务语句
|
||||
crondir=/tmp/cron_$USER
|
||||
crontab -l > $crondir 2>/dev/null
|
||||
sed -i "/$1/d" $crondir
|
||||
sed -i '/^$/d' $crondir
|
||||
echo "$2" >> $crondir
|
||||
crontab $crondir
|
||||
rm -f $crondir
|
||||
tmpcron=/tmp/cron_$USER
|
||||
croncmd -l > $tmpcron
|
||||
sed -i "/$1/d" $tmpcron
|
||||
sed -i '/^$/d' $tmpcron
|
||||
echo "$2" >> $tmpcron
|
||||
croncmd $tmpcron
|
||||
rm -f $tmpcron
|
||||
}
|
||||
mark_time(){
|
||||
start_time=`date +%s`
|
||||
|
||||
Reference in New Issue
Block a user