mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
feat: 默认亮度节点不可用时允许安装但功能保持关闭
- customize.sh: 节点缺失不再中止安装,跳过校准并在安装结尾输出启用指引 - service.sh: 开机检测亮度节点,不存在则不启动守护进程 - restart.sh: 支持守护进程未运行时按需拉起,作为 Web UI 重新启用入口 - daemon.sh: 主循环增加节点守卫,路径无效时挂起监听而非崩溃重启循环
This commit is contained in:
1 parent
dc3ce47b89
commit
c8dbc7f427
4 files changed
+100
-24
No files matched your search
+15
-1
@@ -82,6 +82,21 @@ while true; do
|
||||
fi
|
||||
|
||||
compatibility_mode="$(get_cfg compatibility_mode "0")"
|
||||
now_bri_file="${current_config%|*}"
|
||||
|
||||
# 亮度节点不存在时挂起监听 (功能未启用或路径配置错误),等待节点出现或配置变更
|
||||
if [ ! -f "$now_bri_file" ]; then
|
||||
if [ -z "$node_wait_logged" ]; then
|
||||
_log "亮度节点不存在: $now_bri_file,功能挂起,每 10 秒重试" "ERROR"
|
||||
node_wait_logged=1
|
||||
fi
|
||||
sleep 10
|
||||
continue
|
||||
fi
|
||||
if [ -n "$node_wait_logged" ]; then
|
||||
_log "亮度节点已就绪: $now_bri_file" "INFO"
|
||||
node_wait_logged=""
|
||||
fi
|
||||
|
||||
if [ "$compatibility_mode" = "1" ]; then
|
||||
_log "兼容模式已开启 (轮询驱动)" "WARN"
|
||||
@@ -102,7 +117,6 @@ while true; do
|
||||
_log "轮询模式已退出" "INFO"
|
||||
else
|
||||
_log "正在启动 lumipro 监听" "INFO"
|
||||
now_bri_file="${current_config%|*}"
|
||||
inotify_events="${current_config#*|}"
|
||||
debug_mode="$(get_cfg debug_mode "0")"
|
||||
|
||||
|
||||
+30
-2
@@ -6,6 +6,20 @@ PID_DIR="$MODDIR/pid"
|
||||
pid_file="$PID_DIR/inotifyd.pid"
|
||||
flag_file="$PID_DIR/up.flag"
|
||||
log_file="$MODDIR/service.log"
|
||||
CONFIG_FILE="$MODDIR/config/config.json"
|
||||
JQ="$MODDIR/bin/jq"
|
||||
|
||||
DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness"
|
||||
|
||||
get_cfg() {
|
||||
local key="$1" default="$2"
|
||||
local val
|
||||
if val=$("$JQ" -re ".${key}" "$CONFIG_FILE" 2>/dev/null); then
|
||||
echo "$val"
|
||||
else
|
||||
echo "$default"
|
||||
fi
|
||||
}
|
||||
|
||||
_log() {
|
||||
printf '[%s] [restart] %s\n' "$(date '+%d %H:%M:%S.%3N')" "$1" >>"$log_file"
|
||||
@@ -26,8 +40,22 @@ rm -f "$flag_file"
|
||||
rm -f "$PID_DIR/up.lock"
|
||||
_log "已清理锁文件"
|
||||
|
||||
# 3. 恢复守护进程 (它会自动拉起新 inotifyd)
|
||||
# 3. 恢复守护进程 (它会自动拉起新监听)
|
||||
rm -f "$pause_file"
|
||||
_log "守护进程已恢复,等待自动拉起监听"
|
||||
|
||||
# 4. 守护进程未运行时 (亮度节点不可用导致服务未启动),按需拉起
|
||||
if ! pgrep -f "script/daemon.sh" >/dev/null 2>&1; then
|
||||
now_bri_file="$(get_cfg now_bri_file "$DEFAULT_NOW_BRI_FILE")"
|
||||
if [ ! -f "$now_bri_file" ]; then
|
||||
_log "亮度节点不存在 ($now_bri_file),拒绝启动服务"
|
||||
echo "亮度节点不存在: $now_bri_file,无法启动服务,请先在配置页填写正确路径" >&2
|
||||
exit 1
|
||||
fi
|
||||
_log "守护进程未运行,正在启动"
|
||||
sh "$MODDIR/script/daemon.sh" &
|
||||
_log "守护进程已启动 (PID: $!)"
|
||||
else
|
||||
_log "守护进程已恢复,等待自动拉起监听"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in new issue
Block a user