Add LuCI services menu entry
This commit is contained in:
1 parent
e891cc1b71
commit
137227389a
5 files changed
+40
No files matched your search
@@ -11,3 +11,4 @@ uninstall.sh text eol=lf
|
||||
files/usr/sbin/owrt-full-backup text eol=lf
|
||||
files/etc/config/fullbackup 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
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
- `/usr/sbin/owrt-full-backup` - консольная команда;
|
||||
- `/www/cgi-bin/owrt-full-backup` - веб-панель;
|
||||
- `/usr/lib/lua/luci/controller/owrt_full_backup.lua` - пункт меню LuCI;
|
||||
- `/etc/config/fullbackup` - настройки по умолчанию;
|
||||
- `/etc/owrt-full-backup/web.key` - секретный ключ для входа в панель.
|
||||
|
||||
@@ -35,6 +36,14 @@ http://192.168.1.1/cgi-bin/owrt-full-backup?key=SECRET
|
||||
|
||||
Эту ссылку никому не отдавай: ключ в 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
|
||||
@@ -103,6 +103,9 @@ install_file "usr/sbin/owrt-full-backup" 0755
|
||||
ln -sf owrt-full-backup "$(target_path usr/sbin/owrt-backup)"
|
||||
install_config
|
||||
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
|
||||
"$(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)"
|
||||
|
||||
info "Веб-панель OpenWrt Full Backup установлена."
|
||||
info "LuCI: Службы -> OpenWrt Full Backup"
|
||||
info "Открыть: http://$ip/cgi-bin/owrt-full-backup?key=$key"
|
||||
info "CLI: owrt-full-backup create -o /mnt/usb"
|
||||
@@ -16,6 +16,7 @@ rmf() {
|
||||
rmf usr/sbin/owrt-full-backup
|
||||
rmf usr/sbin/owrt-backup
|
||||
rmf www/cgi-bin/owrt-full-backup
|
||||
rmf usr/lib/lua/luci/controller/owrt_full_backup.lua
|
||||
|
||||
if [ "$PURGE" = "1" ]; then
|
||||
rmf etc/config/fullbackup
|
||||
@@ -23,6 +24,8 @@ if [ "$PURGE" = "1" ]; then
|
||||
rmdir "$(target_path etc/owrt-full-backup)" 2>/dev/null || true
|
||||
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
|
||||
"$(target_path etc/init.d/uhttpd)" reload >/dev/null 2>&1 || "$(target_path etc/init.d/uhttpd)" restart >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user