feat: focus panel on rgb leds and speed boot
This commit is contained in:
+9
-3
@@ -7,6 +7,7 @@ CONFIG_DIR="/etc/led-manager"
|
||||
CONFIG_FILE="$CONFIG_DIR/config.json"
|
||||
PORT="${PORT:-8088}"
|
||||
HOST="${HOST:-0.0.0.0}"
|
||||
COLORS="${COLORS:-red,green,blue}"
|
||||
RAW_BASE="${RAW_BASE:-https://gitea.chickliu.fun/Hermes/led-manager-panel/raw/branch/main}"
|
||||
|
||||
need_root() {
|
||||
@@ -52,12 +53,15 @@ install_systemd_service() {
|
||||
|
||||
echo "安装 systemd 服务:$APP_NAME"
|
||||
download "$RAW_BASE/led-manager.service" "/etc/systemd/system/$APP_NAME.service"
|
||||
# Patch host/port/config in service if env overrides were provided.
|
||||
sed -i "s#--host [^ ]* --port [0-9]* --config [^ ]*#--host $HOST --port $PORT --config $CONFIG_FILE#" "/etc/systemd/system/$APP_NAME.service" || true
|
||||
# Patch host/port/config/colors in service if env overrides were provided.
|
||||
sed -i "s#--host [^ ]* --port [0-9]* --config [^ ]*#--host $HOST --port $PORT --config $CONFIG_FILE --colors $COLORS#" "/etc/systemd/system/$APP_NAME.service" || true
|
||||
if ! grep -q -- '--colors' "/etc/systemd/system/$APP_NAME.service"; then
|
||||
sed -i "s#\(ExecStart=.*\)#\1 --colors $COLORS#" "/etc/systemd/system/$APP_NAME.service" || true
|
||||
fi
|
||||
systemctl daemon-reload
|
||||
systemctl enable "$APP_NAME"
|
||||
systemctl restart "$APP_NAME"
|
||||
systemctl status "$APP_NAME" --no-pager || true
|
||||
systemctl is-active "$APP_NAME" >/dev/null 2>&1 && echo "服务已启动:$APP_NAME" || systemctl status "$APP_NAME" --no-pager || true
|
||||
}
|
||||
|
||||
need_root
|
||||
@@ -89,4 +93,6 @@ echo "服务:systemctl status $APP_NAME"
|
||||
echo "配置:$CONFIG_FILE"
|
||||
echo "访问地址: http://${ipaddr:-设备IP}:$PORT/"
|
||||
echo "面板里点『保存持久化』后,重启系统会由 systemd 启动本项目并自动读取配置恢复 LED。"
|
||||
echo "当前只显示/控制颜色:$COLORS"
|
||||
echo "如需修改端口:PORT=8090 sh install.sh"
|
||||
echo "如需显示全部 LED:COLORS= sh install.sh"
|
||||
|
||||
Reference in New Issue
Block a user