mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-03 15:13:56 +08:00
🍓 Sync 2026-05-03 02:17:23
This commit is contained in:
1 parent
a4128ab3aa
commit
373acbfdda
2 files changed
+65
-68
No files matched your search
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=luci-app-passwall
|
PKG_NAME:=luci-app-passwall
|
||||||
PKG_VERSION:=26.4.15
|
PKG_VERSION:=26.4.15
|
||||||
PKG_RELEASE:=107
|
PKG_RELEASE:=108
|
||||||
PKG_PO_VERSION:=$(PKG_VERSION)
|
PKG_PO_VERSION:=$(PKG_VERSION)
|
||||||
|
|
||||||
PKG_CONFIG_DEPENDS:= \
|
PKG_CONFIG_DEPENDS:= \
|
||||||
|
|||||||
@@ -1129,109 +1129,106 @@ clean_crontab() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_crontab() {
|
start_crontab() {
|
||||||
if [ "$ENABLED_DEFAULT_ACL" == 1 ] || [ "$ENABLED_ACLS" == 1 ]; then
|
local update_loop
|
||||||
start_daemon=$(config_t_get global_delay start_daemon 0)
|
|
||||||
[ "$start_daemon" = "1" ] && $APP_PATH/monitor.sh > /dev/null 2>&1 &
|
if [ "$ENABLED_DEFAULT_ACL" = "1" ] || [ "$ENABLED_ACLS" = "1" ]; then
|
||||||
|
local start_daemon=$(config_t_get global_delay start_daemon 0)
|
||||||
|
[ "$start_daemon" = "1" ] && $APP_PATH/monitor.sh >/dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -f "${LOCK_PATH}/${CONFIG}_cron.lock" ] && {
|
if [ -f "${LOCK_PATH}/${CONFIG}_cron.lock" ]; then
|
||||||
rm -f "${LOCK_PATH}/${CONFIG}_cron.lock"
|
rm -f "${LOCK_PATH}/${CONFIG}_cron.lock"
|
||||||
echolog "当前为计划任务自动运行,不重新配置定时任务。"
|
echolog "当前为计划任务自动运行,不重新配置定时任务。"
|
||||||
return
|
return
|
||||||
}
|
fi
|
||||||
|
|
||||||
clean_crontab
|
clean_crontab
|
||||||
|
|
||||||
[ "$ENABLED" != 1 ] && {
|
if [ "$ENABLED" != "1" ]; then
|
||||||
/etc/init.d/cron restart
|
/etc/init.d/cron restart
|
||||||
return
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_time() {
|
||||||
|
local w="$1"
|
||||||
|
local h="$2"
|
||||||
|
local expr="0 $h * * $w"
|
||||||
|
[ "$w" = "7" ] && expr="0 $h * * *"
|
||||||
|
echo "$expr"
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_week_mode=$(config_t_get global_delay stop_week_mode)
|
add_service_cron() {
|
||||||
stop_time_mode=$(config_t_get global_delay stop_time_mode)
|
local week="$1"
|
||||||
if [ -n "$stop_week_mode" ]; then
|
local hour="$2"
|
||||||
local t="0 $stop_time_mode * * $stop_week_mode"
|
local action="$3"
|
||||||
[ "$stop_week_mode" = "7" ] && t="0 $stop_time_mode * * *"
|
local logmsg="$4"
|
||||||
if [ "$stop_week_mode" = "8" ]; then
|
[ -z "$week" ] && return
|
||||||
|
local svr_t=$(build_time "$week" "$hour")
|
||||||
|
if [ "$week" = "8" ]; then
|
||||||
update_loop=1
|
update_loop=1
|
||||||
else
|
else
|
||||||
echo "$t /etc/init.d/$CONFIG stop > /dev/null 2>&1 &" >>/etc/crontabs/root
|
echo "$svr_t /etc/init.d/$CONFIG $action > /dev/null 2>&1 &" >>/etc/crontabs/root
|
||||||
fi
|
fi
|
||||||
echolog "配置定时任务:自动关闭服务。"
|
echolog "$logmsg"
|
||||||
fi
|
}
|
||||||
start_week_mode=$(config_t_get global_delay start_week_mode)
|
|
||||||
start_time_mode=$(config_t_get global_delay start_time_mode)
|
|
||||||
if [ -n "$start_week_mode" ]; then
|
|
||||||
local t="0 $start_time_mode * * $start_week_mode"
|
|
||||||
[ "$start_week_mode" = "7" ] && t="0 $start_time_mode * * *"
|
|
||||||
if [ "$start_week_mode" = "8" ]; then
|
|
||||||
update_loop=1
|
|
||||||
else
|
|
||||||
echo "$t /etc/init.d/$CONFIG start > /dev/null 2>&1 &" >>/etc/crontabs/root
|
|
||||||
fi
|
|
||||||
echolog "配置定时任务:自动开启服务。"
|
|
||||||
fi
|
|
||||||
restart_week_mode=$(config_t_get global_delay restart_week_mode)
|
|
||||||
restart_time_mode=$(config_t_get global_delay restart_time_mode)
|
|
||||||
if [ -n "$restart_week_mode" ]; then
|
|
||||||
local t="0 $restart_time_mode * * $restart_week_mode"
|
|
||||||
[ "$restart_week_mode" = "7" ] && t="0 $restart_time_mode * * *"
|
|
||||||
if [ "$restart_week_mode" = "8" ]; then
|
|
||||||
update_loop=1
|
|
||||||
else
|
|
||||||
echo "$t /etc/init.d/$CONFIG restart > /dev/null 2>&1 &" >>/etc/crontabs/root
|
|
||||||
fi
|
|
||||||
echolog "配置定时任务:自动重启服务。"
|
|
||||||
fi
|
|
||||||
|
|
||||||
autoupdate=$(config_t_get global_rules auto_update)
|
# ===== stop/start/restart =====
|
||||||
weekupdate=$(config_t_get global_rules week_update)
|
add_service_cron "$(config_t_get global_delay stop_week_mode)" "$(config_t_get global_delay stop_time_mode)" "stop" "配置定时任务:自动关闭服务。"
|
||||||
dayupdate=$(config_t_get global_rules time_update)
|
|
||||||
|
add_service_cron "$(config_t_get global_delay start_week_mode)" "$(config_t_get global_delay start_time_mode)" "start" "配置定时任务:自动开启服务。"
|
||||||
|
|
||||||
|
add_service_cron "$(config_t_get global_delay restart_week_mode)" "$(config_t_get global_delay restart_time_mode)" "restart" "配置定时任务:自动重启服务。"
|
||||||
|
|
||||||
|
# ===== rule update =====
|
||||||
|
local autoupdate=$(config_t_get global_rules auto_update)
|
||||||
|
local weekupdate=$(config_t_get global_rules week_update)
|
||||||
|
local dayupdate=$(config_t_get global_rules time_update)
|
||||||
if [ "$autoupdate" = "1" ]; then
|
if [ "$autoupdate" = "1" ]; then
|
||||||
local t="0 $dayupdate * * $weekupdate"
|
local rule_t=$(build_time "$weekupdate" "$dayupdate")
|
||||||
[ "$weekupdate" = "7" ] && t="0 $dayupdate * * *"
|
|
||||||
if [ "$weekupdate" = "8" ]; then
|
if [ "$weekupdate" = "8" ]; then
|
||||||
update_loop=1
|
update_loop=1
|
||||||
else
|
else
|
||||||
echo "$t lua $APP_PATH/rule_update.lua log all cron > /dev/null 2>&1 &" >>/etc/crontabs/root
|
echo "$rule_t lua $APP_PATH/rule_update.lua log all cron > /dev/null 2>&1 &" >>/etc/crontabs/root
|
||||||
fi
|
fi
|
||||||
echolog "配置定时任务:自动更新规则。"
|
echolog "配置定时任务:自动更新规则。"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TMP_SUB_PATH=$TMP_PATH/sub_crontabs
|
# ===== subscribe =====
|
||||||
mkdir -p $TMP_SUB_PATH
|
local TMP_SUB_PATH=$TMP_PATH/sub_crontabs
|
||||||
|
mkdir -p "$TMP_SUB_PATH"
|
||||||
|
local item cfgid remark week_update time_update
|
||||||
for item in $(uci show ${CONFIG} | grep "=subscribe_list" | cut -d '.' -sf 2 | cut -d '=' -sf 1); do
|
for item in $(uci show ${CONFIG} | grep "=subscribe_list" | cut -d '.' -sf 2 | cut -d '=' -sf 1); do
|
||||||
if [ "$(config_n_get $item auto_update 0)" = "1" ]; then
|
if [ "$(config_n_get "$item" auto_update 0)" = "1" ]; then
|
||||||
cfgid=$(uci show ${CONFIG}.$item | head -n 1 | cut -d '.' -sf 2 | cut -d '=' -sf 1)
|
cfgid=$(uci show ${CONFIG}.$item | head -n 1 | cut -d '.' -sf 2 | cut -d '=' -sf 1)
|
||||||
remark=$(config_n_get $item remark)
|
remark=$(config_n_get "$item" remark)
|
||||||
week_update=$(config_n_get $item week_update)
|
week_update=$(config_n_get "$item" week_update)
|
||||||
time_update=$(config_n_get $item time_update)
|
time_update=$(config_n_get "$item" time_update)
|
||||||
echo "$cfgid" >> $TMP_SUB_PATH/${week_update}_${time_update}
|
echo "$cfgid" >> "$TMP_SUB_PATH/${week_update}_${time_update}"
|
||||||
echolog "配置定时任务:自动更新【$remark】订阅。"
|
echolog "配置定时任务:自动更新【$remark】订阅。"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [ -d "$TMP_SUB_PATH" ]; then
|
||||||
[ -d "${TMP_SUB_PATH}" ] && {
|
local name cfgids
|
||||||
for name in $(ls ${TMP_SUB_PATH}); do
|
for name in $(ls "$TMP_SUB_PATH"); do
|
||||||
week_update=$(echo $name | awk -F '_' '{print $1}')
|
week_update=${name%_*}
|
||||||
time_update=$(echo $name | awk -F '_' '{print $2}')
|
time_update=${name#*_}
|
||||||
cfgids=$(echo -n $(cat ${TMP_SUB_PATH}/${name}) | sed 's# #,#g')
|
cfgids=$(tr '\n' ',' < "$TMP_SUB_PATH/$name" | sed 's/,$//')
|
||||||
local t="0 $time_update * * $week_update"
|
local sub_t=$(build_time "$week_update" "$time_update")
|
||||||
[ "$week_update" = "7" ] && t="0 $time_update * * *"
|
|
||||||
if [ "$week_update" = "8" ]; then
|
if [ "$week_update" = "8" ]; then
|
||||||
update_loop=1
|
update_loop=1
|
||||||
else
|
else
|
||||||
echo "$t lua $APP_PATH/subscribe.lua start $cfgids cron > /dev/null 2>&1 &" >>/etc/crontabs/root
|
echo "$sub_t lua $APP_PATH/subscribe.lua start $cfgids cron > /dev/null 2>&1 &" >>/etc/crontabs/root
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
rm -rf $TMP_SUB_PATH
|
rm -rf "$TMP_SUB_PATH"
|
||||||
}
|
fi
|
||||||
|
|
||||||
if [ "$ENABLED_DEFAULT_ACL" == 1 ] || [ "$ENABLED_ACLS" == 1 ]; then
|
# ===== loop =====
|
||||||
[ "$update_loop" = "1" ] && {
|
if [ "$ENABLED_DEFAULT_ACL" = "1" ] || [ "$ENABLED_ACLS" = "1" ]; then
|
||||||
$APP_PATH/tasks.sh > /dev/null 2>&1 &
|
if [ "$update_loop" = "1" ]; then
|
||||||
|
$APP_PATH/tasks.sh >/dev/null 2>&1 &
|
||||||
echolog "自动更新:启动循环更新进程。"
|
echolog "自动更新:启动循环更新进程。"
|
||||||
}
|
fi
|
||||||
else
|
else
|
||||||
echolog "运行于非代理模式,仅允许服务启停的定时任务。"
|
echolog "运行于非代理模式,仅允许服务启停的定时任务。"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in new issue
Block a user