luci-app-advanced-reboot: bugfix: support new board names for Linksys WRT-devices 4152/head
authorStan Grishin <stangri@melmac.net>
Wed, 10 Jun 2020 16:48:55 +0000 (16:48 +0000)
committerStan Grishin <stangri@melmac.net>
Wed, 10 Jun 2020 16:48:55 +0000 (16:48 +0000)
Signed-off-by: Stan Grishin <stangri@melmac.net>
17 files changed:
applications/luci-app-advanced-reboot/Makefile
applications/luci-app-advanced-reboot/README.md
applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-e4200v2-ea4500.lua
applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea3500.lua
applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea6350v3.lua
applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea8300.lua
applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea8500.lua
applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1200ac.lua
applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1900ac.lua
applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1900acs.lua
applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1900acv2.lua
applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt3200acm.lua
applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt32x.lua
applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/zyxel-nbg6817.lua
applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua
applications/luci-app-advanced-reboot/po/templates/advanced-reboot.pot
applications/luci-app-advanced-reboot/root/usr/share/rpcd/acl.d/luci-app-advanced-reboot.json [new file with mode: 0644]

index e119e6acc23f7a4bf6aef2262990a451a65e4e92..79197c43ba04eb74e456c41712d87d6e23d03dd8 100644 (file)
@@ -10,10 +10,9 @@ LUCI_TITLE:=Advanced Linksys Reboot Web UI
 LUCI_DESCRIPTION:=Provides Web UI (found under System/Advanced Reboot) to reboot supported Linksys and ZyXEL routers to\
        an alternative partition. Also provides Web UI to shut down (power off) your device.    Supported dual-partition\
        routers are listed at https://github.com/openwrt/luci/blob/master/applications/luci-app-advanced-reboot/README.md
-
 LUCI_DEPENDS:=+luci-compat +luci-mod-admin-full
 LUCI_PKGARCH:=all
-PKG_RELEASE:=52
+PKG_RELEASE:=54
 
 include ../../luci.mk
 
index 5b6ce7126e8ba35dd534b2b0c2be640b012f834c..85c10fcc12260d3fcc11b0cb97697da96fe7d6fe 100644 (file)
@@ -26,7 +26,7 @@ If your device is not in the list above, however it is a [dual-firmware device](
 
 ## Screenshot (luci-app-advanced-reboot)
 
-![screenshot](https://raw.githubusercontent.com/stangri/openwrt_packages/master/screenshots/luci-app-advanced-reboot/screenshot02.png "screenshot")
+![screenshot](https://cdn.jsdelivr.net/gh/stangri/openwrt_packages@master/screenshots/luci-app-advanced-reboot/screenshot02.png "screenshot")
 
 ## How to install
 
@@ -37,7 +37,7 @@ opkg update
 opkg install luci-app-advanced-reboot
 ```
 
-If the ```luci-app-advanced-reboot``` package is not found in the official feed/repo for your version of OpenWrt/LEDE Project, you will need to [add a custom repo to your router](https://github.com/stangri/openwrt_packages/blob/master/README.md#on-your-router) first.
+If the ```luci-app-advanced-reboot``` package is not found in the official feed/repo for your version of OpenWrt/LEDE Project, you will need to add a custom repo to your router following instructions on [GitHub](https://github.com/stangri/openwrt_packages/blob/master/README.md#on-your-router)/[jsDelivr](https://cdn.jsdelivr.net/gh/stangri/openwrt_packages@master/README.md#on-your-router) first.
 
 ## Notes/Known Issues
 
index 710ba3ef3c4dbf9faac11a93684d0629ff5fe6ef..6122409dd10757209c3092cf7cca1f00161e3269 100644 (file)
@@ -1,7 +1,7 @@
 return {
        vendorName = "Linksys",
        deviceName = "E4200v2/EA4500",
-       boardName = "linksys-viper",
+       boardNames = { "linksys-viper", "linksys,viper" },
        partition1MTD = "mtd3",
        partition2MTD = "mtd5",
        labelOffset = 32,
index f0ac1febc21f510c7c23729d192764ea3b45adf9..553788fd57a22f2bc88c0a099847770277d34d29 100644 (file)
@@ -1,7 +1,7 @@
 return {
        vendorName = "Linksys",
        deviceName = "EA3500",
-       boardName = "linksys-audi",
+       boardNames = { "linksys-audi", "linksys,audi" },
        partition1MTD = "mtd3",
        partition2MTD = "mtd5",
        labelOffset = 32,
index 5c7aecd1fb4439f5068293785a459c7de67dcffc..ccfe55ead14efa6eeeb6965a961dab0768d8e95a 100644 (file)
@@ -1,7 +1,7 @@
 return {
        vendorName = "Linksys",
        deviceName = "EA6350v3",
-       boardName = "linksys-ea6350v3",
+       boardNames = { "linksys-ea6350v3", "linksys,ea6350v3" },
        partition1MTD = "mtd10",
        partition2MTD = "mtd12",
        labelOffset = 192,
index e0cec8549b8cb29419fd14eb8aa6b732d0c203a9..e5faf278766ee5af016ead2140d5b44d79e57f6d 100644 (file)
@@ -1,7 +1,7 @@
 return {
        vendorName = "Linksys",
        deviceName = "EA8300",
-       boardName = "linksys-ea8300",
+       boardNames = { "linksys-ea8300", "linksys,ea8300" },
        partition1MTD = "mtd10",
        partition2MTD = "mtd12",
        labelOffset = 192,
index d60cf61556ee1a0894f345415f8f062e1a08e971..865b72683556228ee004793fd447e81b5acf71ba 100644 (file)
@@ -1,7 +1,7 @@
 return {
        vendorName = "Linksys",
        deviceName = "EA8500",
-       boardName = "linksys-ea8500",
+       boardNames = { "linksys-ea8500", "linksys,ea8500" },
        partition1MTD = "mtd13",
        partition2MTD = "mtd15",
        labelOffset = 32,
index f14fba2c9b9603c136370b709ab5e97f99f7eff6..a3efb69732f9edb4aa208b76a2669fd2213e97c7 100644 (file)
@@ -1,7 +1,7 @@
 return {
        vendorName = "Linksys",
        deviceName = "WRT1200AC",
-       boardName = "linksys-caiman",
+       boardNames = { "linksys-caiman", "linksys,caiman", "linksys,wrt1200ac" },
        partition1MTD = "mtd4",
        partition2MTD = "mtd6",
        labelOffset = 32,
index 01bec1bdebb8fff57bcba43ee241629c8672d029..24869bef822db6db3f6709054324804704e968d0 100644 (file)
@@ -1,7 +1,7 @@
 return {
        vendorName = "Linksys",
-       deviceName = "WRT1900AC",
-       boardName = "linksys-mamba",
+       deviceName = "WRT1900ACv1",
+       boardNames = { "linksys-mamba", "linksys,mamba", "linksys,wrt1900ac-v1" },
        partition1MTD = "mtd4",
        partition2MTD = "mtd6",
        labelOffset = 32,
index f90042338edfdbae5ec31f38871bfce6b6b37d6c..6b409a191f2044f370ca5a79da303cbbb021013b 100644 (file)
@@ -1,7 +1,7 @@
 return {
        vendorName = "Linksys",
        deviceName = "WRT1900ACS",
-       boardName = "linksys-shelby",
+       boardNames = { "linksys-shelby", "linksys,shelby", "linksys,wrt1900acs" },
        partition1MTD = "mtd4",
        partition2MTD = "mtd6",
        labelOffset = 32,
index f9b8244382069acc6e54e4d4aa7f64906e1f376b..15062eb54715794c4a7826cd23c92ffb15a57a6b 100644 (file)
@@ -1,7 +1,7 @@
 return {
        vendorName = "Linksys",
        deviceName = "WRT1900ACv2",
-       boardName = "linksys-cobra",
+       boardNames = { "linksys-cobra", "linksys,cobra", "linksys,wrt1900ac-v2" },
        partition1MTD = "mtd4",
        partition2MTD = "mtd6",
        labelOffset = 32,
index 3efd1a612a182a3f1987dbead4cd70e6d9c62c9c..2e4cbec1a4b6d404d07cf2fab57fcf89c24947e9 100644 (file)
@@ -1,7 +1,7 @@
 return {
        vendorName = "Linksys",
        deviceName = "WRT3200ACM",
-       boardName = "linksys-rango",
+       boardNames = { "linksys-rango", "linksys,rango", "linksys,wrt3200acm" },
        partition1MTD = "mtd5",
        partition2MTD = "mtd7",
        labelOffset = 32,
index 740426362f4a78c43f9a568f516194fa87dda66e..dd9baf5511ca456fef664288dd4259d7b9142ea6 100644 (file)
@@ -1,7 +1,7 @@
 return {
        vendorName = "Linksys",
        deviceName = "WRT32X",
-       boardName = "linksys-venom",
+       boardNames = { "linksys-venom", "linksys,venom", "linksys,wrt32x" },
        partition1MTD = "mtd5",
        partition2MTD = "mtd7",
        labelOffset = nil,
index 4b696227b652782bce4881d9cfc49effe49f2c46..0e91124725705f9626467d285af4ea05981e35a8 100644 (file)
@@ -1,7 +1,7 @@
 return {
        vendorName = "ZyXEL",
        deviceName = "NBG6817",
-       boardName = "nbg6817",
+       boardNames = { "nbg6817" },
        partition1MTD = "mmcblk0p4",
        partition2MTD = "mmcblk0p7",
        labelOffset = 32,
index a8297d7c79d05e642263a66cf16730781f784888..1fb4d461b62d7682fc07ae543c231ab04956ce58 100644 (file)
@@ -1,4 +1,4 @@
--- Copyright 2017-2018 Stan Grishin <stangri@melmac.net>
+-- Copyright 2017-2020 Stan Grishin <stangri@melmac.net>
 -- Licensed to the public under the Apache License 2.0.
 
 module("luci.controller.advanced_reboot", package.seeall)
@@ -98,15 +98,23 @@ function obtain_device_info()
                local p_func = loadfile(devices_dir .. filename)
                setfenv(p_func, { _ = i18n.translate })
                p = p_func()
-               boardName = p.boardName:gsub('%p','')
+               if p.boardName then
+                       boardName = p.boardName:gsub('%p','')
+               end
+               if p.boardNames then
+                       for i, v in pairs(p.boardNames) do
+                               boardName = v:gsub('%p','')
+                               if romBoardName and romBoardName:gsub('%p',''):match(boardName) then break end
+                       end
+               end
                if romBoardName and romBoardName:gsub('%p',''):match(boardName) then
                        if p.labelOffset then
                                if p.partition1MTD then
-                                       p1_label = util.trim(util.exec("dd if=/dev/" .. p.partition1MTD .. " bs=1 skip=" .. p.labelOffset .. " count=128" .. "  2>/dev/null"))
+                                       p1_label = util.trim(util.exec("dd if=/dev/" .. p.partition1MTD .. " bs=1 skip=" .. p.labelOffset .. " count=128" .. " 2>/dev/null"))
                                        n, p1_version = p1_label:match('(Linux)-([%d|.]+)')
                                end
                                if p.partition2MTD then
-                                       p2_label = util.trim(util.exec("dd if=/dev/" .. p.partition2MTD .. " bs=1 skip=" .. p.labelOffset .. " count=128" .. "  2>/dev/null"))
+                                       p2_label = util.trim(util.exec("dd if=/dev/" .. p.partition2MTD .. " bs=1 skip=" .. p.labelOffset .. " count=128" .. " 2>/dev/null"))
                                        n, p2_version = p2_label:match('(Linux)-([%d|.]+)')
                                end
                                if p1_label and p1_label:find("LEDE") then p1_os = "LEDE" end
@@ -160,7 +168,7 @@ function obtain_device_info()
 end
 
 function index()
-       entry({"admin", "system", "advanced_reboot"}, call("action_template"), _("Advanced Reboot"), 90)
+       entry({"admin", "system", "advanced_reboot"}, call("action_template"), _("Advanced Reboot"), 90).acl_depends = { "luci-app-advanced-reboot" }
        entry({"admin", "system", "advanced_reboot", "reboot"}, post("action_reboot"))
        entry({"admin", "system", "advanced_reboot", "alternative_reboot"}, post("action_altreboot"))
        entry({"admin", "system", "advanced_reboot", "power_off"}, post("action_poweroff"))
index 6aabe66a5a935456e49dd3f38b11a39e2b0ee72c..888a9094571b508c21ed38026a88b698788640ad 100644 (file)
@@ -1,7 +1,7 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=UTF-8"
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:163
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:171
 #: applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/advanced_reboot.htm:10
 msgid "Advanced Reboot"
 msgstr ""
@@ -20,8 +20,8 @@ msgstr ""
 msgid "Changes applied."
 msgstr ""
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:123
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:124
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:131
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:132
 msgid "Compressed"
 msgstr ""
 
@@ -43,11 +43,15 @@ msgstr ""
 msgid "Firmware"
 msgstr ""
 
+#: applications/luci-app-advanced-reboot/root/usr/share/rpcd/acl.d/luci-app-advanced-reboot.json:3
+msgid "Grant UCI and file access for luci-app-advanced-reboot"
+msgstr ""
+
 #: applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/applyreboot.htm:45
 msgid "Loading"
 msgstr ""
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:205
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:213
 msgid "No access to fw_printenv or fw_printenv!"
 msgstr ""
 
@@ -90,14 +94,14 @@ msgstr ""
 msgid "Reboot to current partition"
 msgstr ""
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:184
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:256
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:192
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:264
 #: applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/applyreboot.htm:9
 #: applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/applyreboot.htm:39
 msgid "Rebooting..."
 msgstr ""
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:289
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:297
 msgid "Shutting down..."
 msgstr ""
 
@@ -109,7 +113,7 @@ msgstr ""
 msgid "System"
 msgstr ""
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:185
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:193
 msgid ""
 "The system is rebooting now.<br /> DO NOT POWER OFF THE DEVICE!<br /> Wait a "
 "few minutes before you try to reconnect. It might be necessary to renew the "
@@ -117,7 +121,7 @@ msgid ""
 "settings."
 msgstr ""
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:257
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:265
 msgid ""
 "The system is rebooting to an alternative partition now.<br /> DO NOT POWER "
 "OFF THE DEVICE!<br /> Wait a few minutes before you try to reconnect. It "
@@ -125,43 +129,43 @@ msgid ""
 "again, depending on your settings."
 msgstr ""
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:290
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:298
 msgid ""
 "The system is shutting down now.<br /> DO NOT POWER OFF THE DEVICE!<br /> It "
 "might be necessary to renew the address of your computer to reach the device "
 "again, depending on your settings."
 msgstr ""
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:136
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:137
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:240
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:241
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:144
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:145
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:248
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:249
 msgid "Unable to find Dual Boot Flag Partition."
 msgstr ""
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:212
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:213
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:226
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:227
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:220
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:221
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:234
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:235
 msgid "Unable to obtain firmware environment variable: %s."
 msgstr ""
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:248
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:249
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:256
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:257
 msgid "Unable to set Dual Boot Flag Partition entry for partition: %s."
 msgstr ""
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:218
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:219
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:232
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:233
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:226
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:227
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:240
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:241
 msgid "Unable to set firmware environment variable: %s to %s."
 msgstr ""
 
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:118
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:119
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:123
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:124
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:126
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:127
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:131
+#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:132
 msgid "Unknown"
 msgstr ""
 
diff --git a/applications/luci-app-advanced-reboot/root/usr/share/rpcd/acl.d/luci-app-advanced-reboot.json b/applications/luci-app-advanced-reboot/root/usr/share/rpcd/acl.d/luci-app-advanced-reboot.json
new file mode 100644 (file)
index 0000000..50d50bc
--- /dev/null
@@ -0,0 +1,96 @@
+{
+       "luci-app-advanced-reboot": {
+               "description": "Grant UCI and file access for luci-app-advanced-reboot",
+               "read": {
+                       "cgi-io": [
+                               "exec"
+                       ],
+                       "file": {
+                               "/usr/lib/lua/luci/advanced-reboot/devices/*": [
+                                       "read"
+                               ],
+                               "/sys/devices/virtual/ubi/ubi*/mtd_num": [
+                                       "read"
+                               ],
+                               "/etc/os-release": [
+                                       "read"
+                               ],
+                               "/alt/rom/etc/os-release": [
+                                       "read"
+                               ],
+                               "/usr/sbin/fw_printenv *": [
+                                       "exec"
+                               ],
+                               "/usr/sbin/fw_setenv *": [
+                                       "exec"
+                               ],
+                               "/usr/sbin/ubiattach *": [
+                                       "exec"
+                               ],
+                               "/usr/sbin/ubiblock *": [
+                                       "exec"
+                               ],
+                               "/usr/sbin/ubidetach *": [
+                                       "exec"
+                               ],
+                               "/usr/sbin/ubinfo *": [
+                                       "exec"
+                               ],
+                               "/bin/cat *": [
+                                       "exec"
+                               ],
+                               "/usr/bin/cat *": [
+                                       "exec"
+                               ],
+                               "/bin/dd *": [
+                                       "exec"
+                               ],
+                               "/usr/bin/dd *": [
+                                       "exec"
+                               ],
+                               "/bin/hexdump *": [
+                                       "exec"
+                               ],
+                               "/usr/bin/hexdump *": [
+                                       "exec"
+                               ],
+                               "/bin/logger -t advanced-reboot *": [
+                                       "exec"
+                               ],
+                               "/usr/bin/logger -t advanced-reboot *": [
+                                       "exec"
+                               ],
+                               "/bin/mkdir *": [
+                                       "exec"
+                               ],
+                               "/usr/bin/mkdir *": [
+                                       "exec"
+                               ],
+                               "/bin/mount *": [
+                                       "exec"
+                               ],
+                               "/usr/bin/mount *": [
+                                       "exec"
+                               ],
+                               "/bin/printf *": [
+                                       "exec"
+                               ],
+                               "/usr/bin/printf *": [
+                                       "exec"
+                               ],
+                               "/bin/rm *": [
+                                       "exec"
+                               ],
+                               "/usr/bin/rm *": [
+                                       "exec"
+                               ],
+                               "/lib/functions.sh": [
+                                       "exec"
+                               ]
+                       },
+                       "uci": [
+                               "network"
+                       ]
+               }
+       }
+}