Files
2026-09-08 20:01:03 +08:00

172 lines
4.0 KiB
Markdown
Raw Permalink 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.
# luci-app-led-scheduler 0.3.0
## 0.3.0
- 增加 OpenWrt 23.05 / 24.10 兼容。
- OpenWrt 25.12 构建 `.apk`。
- OpenWrt 24.10 / 23.05 构建 `.ipk`。
- 包仍为 `all` 架构,因此同一 OpenWrt 系列的产物不绑定 x86、ARM、MIPS 等 CPU 架构。
- 同时兼容两代 ucitrack:
- OpenWrt 24.10 / 25.12:`/usr/share/ucitrack/*.json`
- OpenWrt 23.05:`/etc/config/ucitrack`
- LuCI 通知兼容:
- 24.10+ 使用 `addTimeLimitedNotification()`
- 23.05 自动退回 `addNotification()` + JavaScript 定时关闭。
- 仓库新增 `.gitea/workflows/build.yml`,一次 CI 同时生成 APK 与 IPK。
### CI 构建矩阵
| OpenWrt | 包格式 | SDK target | Package arch |
| --- | --- | --- | --- |
| 25.12.0 | `.apk` | x86/64 | `all` |
| 24.10.8 | `.ipk` | x86/64 | `all` |
| 23.05.5 | `.ipk` | x86/64 | `all` |
这里故意使用 x86/64 SDK:本项目没有原生二进制,`LUCI_PKGARCH:=all`,
因此 CI 不需要为每一种 CPU 架构重复构建。
## 0.2.4
- 修复无 RTC / 开机时间尚未完成 NTP 同步时,重启后 LED 可能错误保持关闭的问题。
- 开机先恢复 OpenWrt 原生 LED 状态。
- 只有系统时间可信时才立即按计划判断。
- 新增 `/etc/hotplug.d/ntp/90-led-scheduler`,在 NTP `step` / `stratum` 事件后重新执行 `led-control apply`。
- 白天重启不会因为假时间误关灯;夜间重启会在 NTP 校时后按真实时间自动熄灯。
## 0.2.3
- 安装/升级阶段主动执行 `chmod 0755`,避免自定义解压/构建流程丢失 Unix 可执行位后导致 `/etc/init.d/led-scheduler: Permission denied`。
- 同时确保 `/usr/bin/led-control` 具备执行权限。
- 保留 0.2.2 的 ucitrack 自动注册和限时通知修复。
## 0.2.2
- 修复首次安装后 `ucitrack` 未重新扫描,导致 LuCI 保存配置但 cron 不自动更新的问题。
- 安装/升级后按顺序执行:
1. `led-scheduler enable`
2. `ucitrack restart`
3. `rpcd reload`
4. `led-scheduler restart`
- 手动控制成功通知 3 秒后自动消失。
- 操作失败通知 6 秒后自动消失。
- Makefile 补全 OpenWrt buildroot signature。
这个版本只负责 LED 的“定时”,不再自己维护 WAN/LAN 的正常工作方式。
## 设计
OpenWrt 原生页面:
```text
系统 -> LED 配置
```
继续负责:
- WAN / LAN 对应哪个 sysfs LED
- trigger(例如 netdev)
- 网口绑定、Link/TX/RX 等正常行为
本插件:
```text
系统 -> LED 定时
```
只负责:
```text
23:00 -> 临时关闭所选 LED
07:00 -> /etc/init.d/led restart
```
恢复后 LED 会重新按照 `/etc/config/system` 中的原生配置运行。
## 默认配置
```uci
config scheduler 'main'
option enabled '0'
option off_time '23:00'
option on_time '07:00'
option all_system_leds '1'
```
默认不启用定时。
## 页面功能
- 启用 LED 定时
- 关闭时间 / 恢复时间
- 控制全部“系统 -> LED 配置”中的 LED
- 或选择部分 LED
- 立即关闭
- 立即恢复
- 按当前时间应用
- 重新同步 cron
- 显示系统 LED 的名称、sysfs、trigger
## 直接复制到路由器测试
```sh
scp -r root/* root@192.168.2.1:/
scp -r htdocs/* root@192.168.2.1:/www/
```
然后:
```sh
ssh root@192.168.2.1
chmod +x /usr/bin/led-control /etc/init.d/led-scheduler
/etc/init.d/led-scheduler enable
rm -f /tmp/luci-indexcache.*
rm -rf /tmp/luci-modulecache/
/etc/init.d/rpcd restart
/etc/init.d/led-scheduler restart
```
重新登录 LuCI,进入:
```text
系统 -> LED 定时
```
## SSH 调试
```sh
/usr/bin/led-control list
/usr/bin/led-control selected
/usr/bin/led-control status
/usr/bin/led-control off
/usr/bin/led-control on
/usr/bin/led-control sync
```
R2S Plus 当前预计:
```text
WAN wan_led netdev
LAN lan_led netdev
```
## 编译
放入自定义 feed 后:
```sh
./scripts/feeds update myfeed
./scripts/feeds install -p myfeed luci-app-led-scheduler
make defconfig
make package/feeds/myfeed/luci-app-led-scheduler/compile V=s
```
输出为:
```text
luci-app-led-scheduler-0.3.0-r1.apk
```