Add LuCI services menu entry

This commit is contained in:
kzolotarev95 committed 2026-06-28 17:04:35 +04:00
1 parent e891cc1b71
commit 137227389a
5 files changed
+40

No files matched your search

+1
View File
@@ -11,3 +11,4 @@ uninstall.sh text eol=lf
files/usr/sbin/owrt-full-backup text eol=lf files/usr/sbin/owrt-full-backup text eol=lf
files/etc/config/fullbackup text eol=lf files/etc/config/fullbackup text eol=lf
files/www/cgi-bin/owrt-full-backup text eol=lf files/www/cgi-bin/owrt-full-backup text eol=lf
files/usr/lib/lua/luci/controller/owrt_full_backup.lua text eol=lf
+9
View File
@@ -8,6 +8,7 @@
- `/usr/sbin/owrt-full-backup` - консольная команда; - `/usr/sbin/owrt-full-backup` - консольная команда;
- `/www/cgi-bin/owrt-full-backup` - веб-панель; - `/www/cgi-bin/owrt-full-backup` - веб-панель;
- `/usr/lib/lua/luci/controller/owrt_full_backup.lua` - пункт меню LuCI;
- `/etc/config/fullbackup` - настройки по умолчанию; - `/etc/config/fullbackup` - настройки по умолчанию;
- `/etc/owrt-full-backup/web.key` - секретный ключ для входа в панель. - `/etc/owrt-full-backup/web.key` - секретный ключ для входа в панель.
@@ -35,6 +36,14 @@ http://192.168.1.1/cgi-bin/owrt-full-backup?key=SECRET
Эту ссылку никому не отдавай: ключ в URL дает доступ к созданию и восстановлению бэкапов. Эту ссылку никому не отдавай: ключ в URL дает доступ к созданию и восстановлению бэкапов.
Также появится пункт меню LuCI:
```text
Службы -> OpenWrt Full Backup
```
Если пункт не появился сразу, обнови страницу LuCI или выйди и зайди снова.
## Возможности веб-панели ## Возможности веб-панели
- создать полный архив бэкапа; - создать полный архив бэкапа;
@@ -0,0 +1,23 @@
module("luci.controller.owrt_full_backup", package.seeall)
function index()
entry({"admin", "services", "owrt-full-backup"}, call("action_open"), "OpenWrt Full Backup", 90).dependent = false
end
function action_open()
local http = require "luci.http"
local fs = require "nixio.fs"
local key = fs.readfile("/etc/owrt-full-backup/web.key") or ""
key = key:gsub("%s+", "")
if key == "" then
http.prepare_content("text/html; charset=utf-8")
http.write("<!doctype html><html><head><meta charset=\"utf-8\"><title>OpenWrt Full Backup</title></head><body>")
http.write("<h1>OpenWrt Full Backup</h1>")
http.write("<p>Веб-ключ не найден. Переустанови модуль командой <code>sh install.sh</code>.</p>")
http.write("</body></html>")
return
end
http.redirect("/cgi-bin/owrt-full-backup?key=" .. key)
end
+4
View File
@@ -103,6 +103,9 @@ install_file "usr/sbin/owrt-full-backup" 0755
ln -sf owrt-full-backup "$(target_path usr/sbin/owrt-backup)" ln -sf owrt-full-backup "$(target_path usr/sbin/owrt-backup)"
install_config install_config
install_file "www/cgi-bin/owrt-full-backup" 0755 install_file "www/cgi-bin/owrt-full-backup" 0755
install_file "usr/lib/lua/luci/controller/owrt_full_backup.lua" 0644
rm -rf "$(target_path tmp/luci-indexcache)" "$(target_path tmp/luci-modulecache)" 2>/dev/null || true
if [ -x "$(target_path etc/init.d/uhttpd)" ]; then if [ -x "$(target_path etc/init.d/uhttpd)" ]; then
"$(target_path etc/init.d/uhttpd)" reload >/dev/null 2>&1 || "$(target_path etc/init.d/uhttpd)" restart >/dev/null 2>&1 || true "$(target_path etc/init.d/uhttpd)" reload >/dev/null 2>&1 || "$(target_path etc/init.d/uhttpd)" restart >/dev/null 2>&1 || true
@@ -112,5 +115,6 @@ key="$(make_key)"
ip="$(router_ip)" ip="$(router_ip)"
info "Веб-панель OpenWrt Full Backup установлена." info "Веб-панель OpenWrt Full Backup установлена."
info "LuCI: Службы -> OpenWrt Full Backup"
info "Открыть: http://$ip/cgi-bin/owrt-full-backup?key=$key" info "Открыть: http://$ip/cgi-bin/owrt-full-backup?key=$key"
info "CLI: owrt-full-backup create -o /mnt/usb" info "CLI: owrt-full-backup create -o /mnt/usb"
+3
View File
@@ -16,6 +16,7 @@ rmf() {
rmf usr/sbin/owrt-full-backup rmf usr/sbin/owrt-full-backup
rmf usr/sbin/owrt-backup rmf usr/sbin/owrt-backup
rmf www/cgi-bin/owrt-full-backup rmf www/cgi-bin/owrt-full-backup
rmf usr/lib/lua/luci/controller/owrt_full_backup.lua
if [ "$PURGE" = "1" ]; then if [ "$PURGE" = "1" ]; then
rmf etc/config/fullbackup rmf etc/config/fullbackup
@@ -23,6 +24,8 @@ if [ "$PURGE" = "1" ]; then
rmdir "$(target_path etc/owrt-full-backup)" 2>/dev/null || true rmdir "$(target_path etc/owrt-full-backup)" 2>/dev/null || true
fi fi
rm -rf "$(target_path tmp/luci-indexcache)" "$(target_path tmp/luci-modulecache)" 2>/dev/null || true
if [ -x "$(target_path etc/init.d/uhttpd)" ]; then if [ -x "$(target_path etc/init.d/uhttpd)" ]; then
"$(target_path etc/init.d/uhttpd)" reload >/dev/null 2>&1 || "$(target_path etc/init.d/uhttpd)" restart >/dev/null 2>&1 || true "$(target_path etc/init.d/uhttpd)" reload >/dev/null 2>&1 || "$(target_path etc/init.d/uhttpd)" restart >/dev/null 2>&1 || true
fi fi