mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
feat: 新增功能允许用户自定义 inotifyd 要监测的事件(默认是 c),允许通过配置文件和 webui 修改
This commit is contained in:
1 parent
8431079246
commit
b1d2a444c8
8 files changed
+81
-28
No files matched your search
+11
-7
@@ -1,5 +1,6 @@
|
||||
#!/system/bin/sh
|
||||
# LuminPro 守护进程 (Watchdog)
|
||||
#shellcheck shell=ash
|
||||
# LuminPro 守护进程
|
||||
|
||||
# 使用 readlink 获取脚本真实绝对路径
|
||||
REAL_PATH="$(readlink -f "$0")"
|
||||
@@ -31,14 +32,16 @@ get_config() {
|
||||
|
||||
# 获取当前配置的哈希值(用于检测配置变化)
|
||||
get_config_hash() {
|
||||
local now_file="$(get_config "$PATH_CONFIG_DIR/now_bri_file.txt" "$DEFAULT_NOW_BRI_FILE")"
|
||||
echo "$now_file"
|
||||
local now_file events
|
||||
now_file="$(get_config "$PATH_CONFIG_DIR/now_bri_file.txt" "$DEFAULT_NOW_BRI_FILE")"
|
||||
events="$(get_config "$CONFIG_DIR/inotify_events.txt" "c")"
|
||||
echo "${now_file}|${events}"
|
||||
}
|
||||
|
||||
# 日志函数
|
||||
_log() {
|
||||
local level="${2:-INFO}"
|
||||
printf '[%s] [%-8s] [%-8s] %s\n' "$(date '+%m-%d %H:%M:%S')" "daemon" "$level" "$1" >>"$log_file"
|
||||
printf '[%s] [%s] [%s] %s\n' "$(date '+%m-%d %H:%M:%S')" "daemon" "$level" "$1" >>"$log_file"
|
||||
}
|
||||
|
||||
# 确保环境就绪
|
||||
@@ -86,18 +89,19 @@ while true; do
|
||||
|
||||
# 正常启动并监听
|
||||
_log "→ 启动 inotifyd 监听..." "INFO"
|
||||
now_bri_file="$current_config"
|
||||
now_bri_file="${current_config%|*}"
|
||||
inotify_events="${current_config#*|}"
|
||||
|
||||
# 更新缓存,让 up.sh 知道当前监听的是哪个文件
|
||||
echo -n "$now_bri_file" >"$PATH_CONFIG_DIR/.cached_path"
|
||||
|
||||
# 启动并重定向 (不再使用子进程管道以保证 PID 抓取准确)
|
||||
inotifyd "$MODDIR/script/up.sh" "$now_bri_file:c" >>"$log_file" 2>&1 &
|
||||
inotifyd "$MODDIR/script/up.sh" "$now_bri_file:$inotify_events" >>"$log_file" 2>&1 &
|
||||
|
||||
inotify_pid=$!
|
||||
echo "$inotify_pid" >"$pid_file"
|
||||
_log "✓ inotifyd 已启动 (PID: $inotify_pid)" "SUCCESS"
|
||||
_log " 监听文件: $now_bri_file" "INFO"
|
||||
_log " 监听文件: $now_bri_file, 事件: $inotify_events" "INFO"
|
||||
|
||||
# 3. 通过 wait 阻塞,实时感知进程死亡 (兼容所有 BusyBox 环境)
|
||||
wait "$inotify_pid"
|
||||
|
||||
Reference in new issue
Block a user