V6.3.2 删除参数 --corn-rm

This commit is contained in:
Hyy2001X 2021-07-04 12:39:16 +08:00
parent d07825193b
commit 85dec1ec64
1 changed files with 39 additions and 17 deletions

View File

@ -38,7 +38,6 @@ SHELL_HELP() {
-U 仅检查版本更新
-F 强制刷写固件
--skip 跳过固件 SHA256 比对校验 (危险)
--corn-rm 删除所有 AutoUpdate 定时任务
--bak <Path> <Name> 备份 Openwrt 配置文件到用户指定的目录
--clean 清理固件下载缓存
--check 检查 AutoUpdate 依赖软件包
@ -80,6 +79,32 @@ EOF
EXIT 0
}
GET_PID() {
local Result
while [[ $1 ]];do
Result=$(busybox ps | grep "$1" | grep -v "grep" | awk '{print $1}' | awk 'NR==1')
[[ -n ${Result} ]] && echo ${Result}
shift
done
}
KILL_PID() {
while [[ $1 ]];do
kill -9 $1 2>/dev/null
shift
done
}
UCI_GET() {
local Result="$(uci get $1.@$2[0].$3 2>/dev/null)"
[[ -n ${Result} ]] && echo "${Result}"
}
UCI_SET() {
uci set $1.@$2[0].$3=$4 2>/dev/null
uci commit $1
}
LIST_ENV() {
local X
cat /etc/AutoBuild/*_Variable | grep -v '#' | while read X;do
@ -109,7 +134,7 @@ EXIT() {
RUN_TYPE="[UNKNOWN]"
;;
esac
LOGGER "${RUN_TYPE} Command :[${Run_Command}] Finished."
LOGGER "Command :[${Run_Command}] Finished."
exit
}
@ -137,7 +162,7 @@ ECHO() {
LOGGER() {
[[ ! -f ${AutoUpdate_Log_Path}/AutoUpdate.log ]] && touch ${AutoUpdate_Log_Path}/AutoUpdate.log
echo "[$(date "+%Y-%m-%d-%H:%M:%S")] $*" >> ${AutoUpdate_Log_Path}/AutoUpdate.log
echo "[$(date "+%Y-%m-%d-%H:%M:%S")] [$(GET_PID AutoUpdate.sh)] $*" >> ${AutoUpdate_Log_Path}/AutoUpdate.log
}
CHECK_PKG() {
@ -225,10 +250,9 @@ CHANGE_GITHUB() {
ECHO r "错误的 Github 地址,示例: https://github.com/Hyy2001X/AutoBuild-Actions"
EXIT 1
}
UCI_Github_URL=$(uci get autoupdate.@common[0].github 2>/dev/null)
UCI_Github_URL=$(UCI_GET autoupdate common github)
[[ -n ${UCI_Github_URL} && ! ${UCI_Github_URL} == $1 ]] && {
uci set autoupdate.@common[0].github=$1
uci commit autoupdate
UCI_SET autoupdate common github $1
ECHO y "UCI 设置已更新!"
}
[[ ! ${Github} == $1 ]] && {
@ -590,6 +614,14 @@ AutoUpdate_Main() {
while [[ $1 ]];do
case "$1" in
--sleep)
shift
sleep $1
;;
--pid)
shift
GET_PID $*
;;
-V)
shift
case "$1" in
@ -665,16 +697,6 @@ AutoUpdate_Main() {
-n | -f | -u | -T | --test | -P | --proxy | -F)
PREPARE_UPGRADES $*
;;
--corn-rm)
[ ! -f /etc/crontabs/root ] && EXIT 1
shift && [[ -n $* ]] && SHELL_HELP
[[ $(cat /etc/crontabs/root) =~ AutoUpdate ]] && {
sed -i '/AutoUpdate/d' /etc/crontabs/root >/dev/null 2>&1
ECHO y "已删除所有 AutoUpdate 相关计划任务!"
/etc/init.d/cron restart
EXIT 0
} || EXIT 1
;;
-U)
shift && [[ -n $* ]] && SHELL_HELP
CHECK_UPDATES check
@ -738,7 +760,7 @@ AutoUpdate_Main() {
done
}
Version=V6.3.1
Version=V6.3.2
AutoUpdate_Path=/tmp/AutoUpdate
AutoUpdate_Log_Path=/tmp
AutoUpdate_Script_URL=https://ghproxy.com/https://raw.githubusercontent.com/Hyy2001X/AutoBuild-Actions/master/Scripts/AutoUpdate.sh