Files
led-manager-panel/README.md
T

146 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# LED Manager Panel
一个无第三方依赖的 Linux LED Web 管理面板,用 Python 标准库直接管理:
```text
/sys/class/leds/
```
适合 Debian、OpenWrt、Raspberry Pi OS、4G 路由器等 Linux 设备。
你的设备示例:
```text
blue:wan green:wlan mmc0:: red:power sim:en sim:en2 sim:sel sim:sel2
```
## 功能
- 列出 `/sys/class/leds/` 下所有 LED
- 查看 brightness / max_brightness / 当前 trigger
- 打开 / 关闭 LED
- 调整亮度
- 切换 trigger,例如 `none``timer``netdev``mmc0` 等,具体取决于内核暴露的能力
- 设置 `timer` trigger 的 `delay_on` / `delay_off`
- “识别 3 秒”闪烁指定 LED
- 无数据库、无 Node、无 pip 依赖
## 一键安装
```bash
curl -fsSL https://gitea.chickliu.fun/Hermes/led-manager-panel/raw/branch/main/install.sh | sh
```
如果设备没有 `curl`,用 `wget`
```bash
wget -qO- https://gitea.chickliu.fun/Hermes/led-manager-panel/raw/branch/main/install.sh | sh
```
默认端口 `8088`,安装后浏览器打开:
```text
http://设备IP:8088/
```
自定义端口:
```bash
PORT=8090 sh -c "$(curl -fsSL https://gitea.chickliu.fun/Hermes/led-manager-panel/raw/branch/main/install.sh)"
```
## 手动运行
`led_panel.py` 上传到设备,例如:
```bash
scp led_panel.py root@4G-wifi:/root/led_panel.py
```
在设备上运行:
```bash
chmod +x /root/led_panel.py
python3 /root/led_panel.py --host 0.0.0.0 --port 8088
```
如果设备没有 Python3
```bash
# Debian/Ubuntu
apt update && apt install -y python3
# OpenWrt
opkg update && opkg install python3
```
## Debian systemd 安装
```bash
mkdir -p /opt/led-manager
cp led_panel.py /opt/led-manager/led_panel.py
chmod +x /opt/led-manager/led_panel.py
cp led-manager.service /etc/systemd/system/led-manager.service
systemctl daemon-reload
systemctl enable --now led-manager
systemctl status led-manager
```
默认端口:`8088`
## OpenWrt procd 安装
```bash
mkdir -p /opt/led-manager
cp led_panel.py /opt/led-manager/led_panel.py
chmod +x /opt/led-manager/led_panel.py
cp led-manager.openwrt.init /etc/init.d/led-manager
chmod +x /etc/init.d/led-manager
/etc/init.d/led-manager enable
/etc/init.d/led-manager start
/etc/init.d/led-manager status
```
## 安全说明
这个面板会写 `/sys/class/leds/*`,建议只在内网使用,不要直接暴露公网。
如需公网访问,请放到反代后面加认证,或者只监听 `127.0.0.1`
```bash
python3 /root/led_panel.py --host 127.0.0.1 --port 8088
```
## 常见问题
### 1. 按钮提示权限不足
需要 root 运行,因为 `/sys/class/leds/*/brightness` 通常只有 root 可写。
### 2. 某些 LED 不能调亮度
有些 LED 只有 `0/1` 两档,`max_brightness` 会是 `1`
### 3. 切换 trigger 后亮度不能手动控制
Linux LED 子系统里,手动亮度通常要先切回:
```bash
echo none > /sys/class/leds/<led-name>/trigger
```
面板在手动设置亮度时会自动尝试切到 `none`
### 4. netdev trigger 怎么绑定网卡?
如果某个 LED 支持 `netdev` trigger,切到 netdev 后可能会出现这些文件:
```text
device_name
link
tx
rx
```
当前版本先做通用亮度/trigger/timer 管理;如果你要把 `blue:wan` 绑定到具体网卡,我可以继续加 netdev 绑定配置。