mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2025-12-06 11:36:48 +03:00
66 lines
1.9 KiB
Diff
66 lines
1.9 KiB
Diff
From 069fb25032d1b85ea57615ca234752e3969b777b Mon Sep 17 00:00:00 2001
|
|
From: remittor <remittor@gmail.com>
|
|
Date: Sat, 8 Feb 2025 22:04:51 +0300
|
|
Subject: [PATCH] Add support log file for each daemons
|
|
|
|
---
|
|
diff --git a/common/custom.sh b/common/custom.sh
|
|
index 0af19c0..41c0967 100644
|
|
--- a/common/custom.sh
|
|
+++ b/common/custom.sh
|
|
@@ -13,9 +13,16 @@ custom_runner()
|
|
dir_is_not_empty "$CUSTOM_DIR/custom.d" && {
|
|
for script in "$CUSTOM_DIR/custom.d/"*; do
|
|
[ -f "$script" ] || continue
|
|
+ DAEMON_CFGNAME_SAVED="$DAEMON_CFGNAME"
|
|
+ unset DAEMON_CFGNAME
|
|
unset -f $FUNC
|
|
. "$script"
|
|
+ if [ -z "$DAEMON_CFGNAME" ]; then
|
|
+ DAEMON_CFGNAME="$(basename "$script")"
|
|
+ DAEMON_CFGNAME="${DAEMON_CFGNAME%%.*}"
|
|
+ fi
|
|
existf $FUNC && $FUNC "$@"
|
|
+ DAEMON_CFGNAME="$DAEMON_CFGNAME_SAVED"
|
|
done
|
|
}
|
|
}
|
|
diff --git a/init.d/openwrt/zapret b/init.d/openwrt/zapret
|
|
index 8d6d3a9..fcb1e91 100755
|
|
--- a/init.d/openwrt/zapret
|
|
+++ b/init.d/openwrt/zapret
|
|
@@ -58,12 +58,29 @@ run_daemon()
|
|
# use $PIDDIR/$DAEMONBASE$1.pid as pidfile
|
|
local DAEMONBASE="$(basename "$2")"
|
|
echo "Starting daemon $1: $2 $3"
|
|
+ local DAEMON_NAME="$DAEMONBASE"
|
|
+ local DAEMON_IDNUM=$1
|
|
+ local DAEMON_PATH="$2"
|
|
+ local DAEMON_ARGS="$3"
|
|
+ local DAEMON_LOG=
|
|
+ if [ -n "$DAEMON_LOG_FILE" ]; then
|
|
+ DAEMON_LOG="$DAEMON_LOG_FILE"
|
|
+ DAEMON_LOG=${DAEMON_LOG/<DAEMON_NAME>/$DAEMON_NAME}
|
|
+ DAEMON_LOG=${DAEMON_LOG/<DAEMON_IDNUM>/$DAEMON_IDNUM}
|
|
+ DAEMON_LOG=${DAEMON_LOG/<DAEMON_CFGNAME>/$DAEMON_CFGNAME}
|
|
+ [ -f "$DAEMON_LOG" ] && rm -f "$DAEMON_LOG"
|
|
+ if [ "$DAEMON_LOG_ENABLE" = "1" ]; then
|
|
+ DAEMON_ARGS="--debug=@$DAEMON_LOG $DAEMON_ARGS"
|
|
+ fi
|
|
+ fi
|
|
procd_open_instance
|
|
- procd_set_param command $2 $3
|
|
+ procd_set_param command $DAEMON_PATH $DAEMON_ARGS
|
|
procd_set_param pidfile $PIDDIR/$DAEMONBASE$1.pid
|
|
procd_close_instance
|
|
}
|
|
|
|
+DAEMON_CFGNAME="main"
|
|
+
|
|
run_tpws()
|
|
{
|
|
[ "$DISABLE_IPV4" = "1" ] && [ "$DISABLE_IPV6" = "1" ] && return 0
|
|
--
|
|
2.41.0.windows.3
|
|
|