mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-03 00:33:56 +08:00
update 2026-09-28 18:25:11
This commit is contained in:
1 parent
5b56b0238b
commit
5a3dad58e1
189 files changed
+59
-41779
No files matched your search
@@ -6,11 +6,10 @@ STOP=15
|
||||
ROOT="${IPKG_INSTROOT:-}"
|
||||
. "$ROOT/usr/share/passwall/utils.sh"
|
||||
APP_FILE=${APP_PATH}/app.sh
|
||||
LOCK_FILE_DIR=/var/lock
|
||||
LOCK_FILE=${LOCK_FILE_DIR}/${CONFIG}.lock
|
||||
LOCK_FILE=${LOCK_PATH}/${CONFIG}.lock
|
||||
|
||||
set_lock() {
|
||||
[ ! -d "$LOCK_FILE_DIR" ] && mkdir -p $LOCK_FILE_DIR
|
||||
[ ! -d "$LOCK_PATH" ] && mkdir -p $LOCK_PATH
|
||||
exec 999>"$LOCK_FILE"
|
||||
flock -xn 999
|
||||
}
|
||||
@@ -34,13 +33,16 @@ unlock() {
|
||||
}
|
||||
|
||||
boot_func() {
|
||||
rm -f ${LOCK_PATH}/${CONFIG}_ready.lock
|
||||
rm -f ${LOCK_PATH}/${CONFIG}_rule_update.lock
|
||||
rm -f ${LOCK_PATH}/${CONFIG}_subscribe.lock
|
||||
local delay=$(uci -q get ${CONFIG}.@global_delay[0].start_delay || echo 1)
|
||||
if [ "$delay" -gt 0 ]; then
|
||||
echolog "执行启动延时 $delay 秒后再启动!"
|
||||
sleep $delay
|
||||
fi
|
||||
restart boot
|
||||
touch ${LOCK_FILE_DIR}/${CONFIG}_ready.lock
|
||||
touch ${LOCK_PATH}/${CONFIG}_ready.lock
|
||||
}
|
||||
|
||||
boot() {
|
||||
@@ -50,7 +52,7 @@ boot() {
|
||||
start() {
|
||||
set_lock
|
||||
[ $? == 1 ] && echolog "脚本已经在运行,不重复运行,退出." && exit 0
|
||||
$APP_FILE start
|
||||
$APP_FILE start $2
|
||||
unset_lock
|
||||
}
|
||||
|
||||
@@ -58,15 +60,17 @@ stop() {
|
||||
unlock
|
||||
set_lock
|
||||
[ $? == 1 ] && echolog "停止脚本等待超时,不重复运行,退出." && exit 0
|
||||
$APP_FILE stop
|
||||
$APP_FILE stop $2
|
||||
unset_lock
|
||||
}
|
||||
|
||||
restart() {
|
||||
local action=${2:-$1}
|
||||
[ "$action" = "restart" ] && action=
|
||||
set_lock
|
||||
[ $? == 1 ] && echolog "脚本已经在运行,不重复运行,退出." && exit 0
|
||||
rule_lock=${LOCK_FILE_DIR}/${CONFIG}_rule_update.lock
|
||||
sub_lock=${LOCK_FILE_DIR}/${CONFIG}_subscribe.lock
|
||||
rule_lock=${LOCK_PATH}/${CONFIG}_rule_update.lock
|
||||
sub_lock=${LOCK_PATH}/${CONFIG}_subscribe.lock
|
||||
for i in $(seq 1 300); do
|
||||
if [ ! -f "$rule_lock" ] && [ ! -f "$sub_lock" ]; then
|
||||
break
|
||||
@@ -74,8 +78,8 @@ restart() {
|
||||
sleep 2
|
||||
done
|
||||
rm -f "$rule_lock" "$sub_lock"
|
||||
$APP_FILE stop
|
||||
$APP_FILE start $1
|
||||
$APP_FILE stop $action
|
||||
$APP_FILE start $action
|
||||
unset_lock
|
||||
}
|
||||
|
||||
|
||||
@@ -918,7 +918,6 @@ socks_node_switch() {
|
||||
}
|
||||
|
||||
clean_crontab() {
|
||||
[ -f "${LOCK_PATH}/${CONFIG}_cron.lock" ] && return
|
||||
touch /etc/crontabs/root
|
||||
#sed -i "/${CONFIG}/d" /etc/crontabs/root >/dev/null 2>&1
|
||||
sed -i "/$(echo "/etc/init.d/${CONFIG}" | sed 's#\/#\\\/#g')/d" /etc/crontabs/root >/dev/null 2>&1
|
||||
@@ -937,8 +936,7 @@ start_crontab() {
|
||||
[ "$start_daemon" = "1" ] && { $APP_PATH/monitor.sh > /dev/null 2>&1 & }
|
||||
fi
|
||||
|
||||
if [ -f "${LOCK_PATH}/${CONFIG}_cron.lock" ]; then
|
||||
rm -f "${LOCK_PATH}/${CONFIG}_cron.lock"
|
||||
if [ "$1" = "cron" ]; then
|
||||
echolog "当前为计划任务自动运行,不重新配置定时任务。"
|
||||
return
|
||||
fi
|
||||
@@ -978,7 +976,7 @@ start_crontab() {
|
||||
if [ "$week" = "8" ]; then
|
||||
update_loop=1
|
||||
else
|
||||
echo "$svr_t /etc/init.d/$CONFIG $action > /dev/null 2>&1 &" >>/etc/crontabs/root
|
||||
echo "$svr_t /etc/init.d/$CONFIG $action cron > /dev/null 2>&1 &" >>/etc/crontabs/root
|
||||
fi
|
||||
echolog "$logmsg"
|
||||
}
|
||||
@@ -1046,7 +1044,7 @@ start_crontab() {
|
||||
}
|
||||
|
||||
stop_crontab() {
|
||||
[ -f "${LOCK_PATH}/${CONFIG}_cron.lock" ] && return
|
||||
[ "$1" = "cron" ] && return
|
||||
clean_crontab
|
||||
/etc/init.d/cron restart
|
||||
#echolog "清除定时执行命令。"
|
||||
@@ -1701,10 +1699,7 @@ start() {
|
||||
}
|
||||
fi
|
||||
|
||||
[ "$1" = "boot" ] && {
|
||||
rm -f "${LOCK_PATH}/${CONFIG}_cron.lock"
|
||||
}
|
||||
start_crontab
|
||||
start_crontab $1
|
||||
echolog "运行完成!\n"
|
||||
|
||||
[ "$ENABLED" = 1 ] && [ "$1" = "boot" ] && {
|
||||
@@ -1741,7 +1736,7 @@ stop() {
|
||||
unset V2RAY_LOCATION_ASSET
|
||||
unset XRAY_LOCATION_ASSET
|
||||
unset SS_SYSTEM_DNS_RESOLVER_FORCE_BUILTIN
|
||||
stop_crontab
|
||||
stop_crontab $1
|
||||
source $APP_PATH/helper_smartdns.sh del
|
||||
rm -rf $GLOBAL_DNSMASQ_CONF
|
||||
rm -rf $GLOBAL_DNSMASQ_CONF_PATH
|
||||
@@ -1890,6 +1885,6 @@ start)
|
||||
start "$@"
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
stop "$@"
|
||||
;;
|
||||
esac
|
||||
@@ -800,15 +800,11 @@ if not rollback then
|
||||
end
|
||||
|
||||
if reboot == 1 then
|
||||
if arg3 == "cron" then
|
||||
if not fs.access(api.LOCK_PREFIX .. ".lock") then
|
||||
luci.sys.call("touch %s_cron.lock" % api.LOCK_PREFIX)
|
||||
end
|
||||
end
|
||||
|
||||
log("重启服务,应用新的规则。")
|
||||
uci_set("@global[0]", "flush_set", "1")
|
||||
uci_save(true, true)
|
||||
uci_save(true)
|
||||
local action = (arg3 == "cron") and " cron" or ""
|
||||
luci.sys.call("/etc/init.d/passwall restart%s > /dev/null 2>&1 &" % action)
|
||||
end
|
||||
log("规则更新完毕...\n")
|
||||
|
||||
|
||||
@@ -2102,14 +2102,9 @@ local function update_node(manual)
|
||||
|
||||
uci_save(true)
|
||||
|
||||
if arg[3] == "cron" then
|
||||
if not fs.access(api.LOCK_PREFIX .. ".lock") then
|
||||
luci.sys.call("touch %s_cron.lock" % api.LOCK_PREFIX)
|
||||
end
|
||||
end
|
||||
|
||||
local action = (arg[3] == "cron") and " cron" or ""
|
||||
if manual ~= 1 then
|
||||
luci.sys.call("/etc/init.d/passwall restart > /dev/null 2>&1 &")
|
||||
luci.sys.call("/etc/init.d/passwall restart%s > /dev/null 2>&1 &" % action)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ do
|
||||
restart_interval_mode=$(expr "$restart_interval_mode" \* 60)
|
||||
if [ -n "$restart_week_mode" ]; then
|
||||
[ "$restart_week_mode" = "8" ] && {
|
||||
[ "$(expr "$CFG_UPDATE_INT" % "$restart_interval_mode")" -eq 0 ] && { /etc/init.d/$CONFIG restart > /dev/null 2>&1 & }
|
||||
[ "$(expr "$CFG_UPDATE_INT" % "$restart_interval_mode")" -eq 0 ] && { /etc/init.d/$CONFIG restart cron > /dev/null 2>&1 & }
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
Reference in new issue
Block a user