From feb8d823e59f8c9bf1bdadce6c7fc2a88966f12e Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Wed, 7 Oct 2020 14:42:39 +0200 Subject: luci-app-advanced-reboot: convert to client side Rework the advanced-reboot app to client side implementation. Change devices file to json type. Signed-off-by: Ansuel Smith Tested-by: Stefan Lippers-Hollmann --- .../root/usr/libexec/rpcd/luci.advanced_reboot | 362 +++++++++++++++++++++ .../devices.disabled/linksys-ea9500.json | 14 + .../devices/linksys-e4200v2-ea4500.json | 14 + .../advanced-reboot/devices/linksys-e4200v2.json | 14 + .../advanced-reboot/devices/linksys-ea3500.json | 15 + .../advanced-reboot/devices/linksys-ea4500.json | 14 + .../advanced-reboot/devices/linksys-ea6350v3.json | 14 + .../advanced-reboot/devices/linksys-ea8300.json | 14 + .../advanced-reboot/devices/linksys-ea8500.json | 14 + .../advanced-reboot/devices/linksys-mr8300.json | 14 + .../advanced-reboot/devices/linksys-wrt1200ac.json | 14 + .../advanced-reboot/devices/linksys-wrt1900ac.json | 14 + .../devices/linksys-wrt1900acs.json | 14 + .../devices/linksys-wrt1900acv2.json | 14 + .../devices/linksys-wrt3200acm.json | 14 + .../advanced-reboot/devices/linksys-wrt32x.json | 14 + .../advanced-reboot/devices/zyxel-nbg6817.json | 14 + .../luci/menu.d/luci-app-advanced-reboot.json | 13 + .../share/rpcd/acl.d/luci-app-advanced-reboot.json | 95 +----- 19 files changed, 607 insertions(+), 88 deletions(-) create mode 100755 applications/luci-app-advanced-reboot/root/usr/libexec/rpcd/luci.advanced_reboot create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices.disabled/linksys-ea9500.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-e4200v2-ea4500.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-e4200v2.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea3500.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea4500.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea6350v3.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea8300.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea8500.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-mr8300.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1200ac.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1900ac.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1900acs.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1900acv2.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt3200acm.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt32x.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/zyxel-nbg6817.json create mode 100644 applications/luci-app-advanced-reboot/root/usr/share/luci/menu.d/luci-app-advanced-reboot.json (limited to 'applications/luci-app-advanced-reboot/root/usr') diff --git a/applications/luci-app-advanced-reboot/root/usr/libexec/rpcd/luci.advanced_reboot b/applications/luci-app-advanced-reboot/root/usr/libexec/rpcd/luci.advanced_reboot new file mode 100755 index 0000000000..a6c7c0e540 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/libexec/rpcd/luci.advanced_reboot @@ -0,0 +1,362 @@ +#!/usr/bin/env lua + +local json = require "luci.jsonc" +local nixio = require "nixio" +local fs = require "nixio.fs" +local sys = require "luci.sys" +local util = require "luci.util" + +local devices_dir = "/usr/share/advanced-reboot/devices/" + +local function logger(t) + util.exec("logger -t advanced-reboot '" .. tostring(t) .. "'") +end + +local function is_alt_mountable(p1_mtd, p2_mtd) + if p1_mtd:sub(1,3) == "mtd" and + p2_mtd:sub(1,3) == "mtd" and + fs.access("/usr/sbin/ubiattach") and + fs.access("/usr/sbin/ubiblock") and + fs.access("/bin/mount") then + return true + else + return false + end +end + +local function alt_partition_mount(op_ubi) + local ubi_dev + util.exec('for i in alt_rom alt_overlay firmware; do [ ! -d "$i" ] && mkdir -p "/alt/${i}"; done') + ubi_dev = tostring(util.exec("ubiattach -m " .. tostring(op_ubi))) + _, _, ubi_dev = ubi_dev:find("UBI device number (%d+)") + if not ubi_dev then + util.exec("ubidetach -m " .. tostring(op_ubi)) + return + end + util.exec("ubiblock --create /dev/ubi" .. ubi_dev .. "_0") + util.exec("mount -t squashfs -o ro /dev/ubiblock" .. ubi_dev .. "_0 /alt/alt_rom") + util.exec("mount -t ubifs /dev/ubi" .. ubi_dev .. "_1 /alt/alt_overlay") +-- util.exec("mount -t overlay overlay -o noatime,lowerdir=/alt/rom,upperdir=/alt/overlay/upper,workdir=/alt/overlay/work /alt/firmware") +end + +local function alt_partition_unmount(op_ubi) + local i + local mtdCount = tonumber(util.exec("ubinfo | grep 'Present UBI devices' | grep -c ','")) + mtdCount = mtdCount and mtdCount + 1 or 10 +-- util.exec("[ -d /alt/firmware ] && umount /alt/firmware") + util.exec("[ -d /alt/alt_overlay ] && umount /alt/alt_overlay") + util.exec("[ -d /alt/alt_rom ] && umount /alt/alt_rom") + for i = 0, mtdCount do + if not fs.access("/sys/devices/virtual/ubi/ubi" .. tostring(i) .. "/mtd_num") then break end + ubi_mtd = tonumber(util.trim(util.exec("cat /sys/devices/virtual/ubi/ubi" .. i .. "/mtd_num"))) + if ubi_mtd and ubi_mtd == op_ubi then + util.exec("ubiblock --remove /dev/ubi" .. tostring(i) .. "_0") + util.exec("ubidetach -m " .. tostring(op_ubi)) + util.exec('rm -rf /alt') + end + end +end + +local function get_partition_os_info(op_ubi) + local cp_info, op_info + if fs.access("/etc/os-release") then + cp_info = util.trim(util.exec('. /etc/os-release && echo "$PRETTY_NAME"')) + if cp_info:find("SNAPSHOT") then + cp_info = util.trim(util.exec('. /etc/os-release && echo "$OPENWRT_RELEASE"')) + end + end + logger(string.format("attempting to mount alternative partition (mtd%s)", tostring(op_ubi))) + alt_partition_unmount(op_ubi) + alt_partition_mount(op_ubi) + if fs.access("/alt/alt_rom/etc/os-release") then + op_info = util.trim(util.exec('. /alt/alt_rom/etc/os-release && echo "$PRETTY_NAME"')) + if op_info:find("SNAPSHOT") then + op_info = util.trim(util.exec('. /alt/alt_rom/etc/os-release && echo "$OPENWRT_RELEASE"')) + end + end + logger(string.format("attempting to unmount alternative partition (mtd%s)", tostring(op_ubi))) + alt_partition_unmount(op_ubi) + return cp_info, op_info +end + +local function find_device_data(romBoardName) + local filename + + for filename in fs.dir(devices_dir) do + local filedata = fs.readfile(devices_dir .. filename) + + local p = json.parse(filedata or {}) + + if p then + local boardName + + if p.boardName then + boardName = p.boardName:gsub('%p','') + if romBoardName:match(boardName) then return p end + end + if p.boardNames then + for i, v in pairs(p.boardNames) do + boardName = v:gsub('%p','') + if romBoardName:match(boardName) then return p end + end + end + end + end + + return nil +end + +local methods = { + obtain_device_info = { + call = function() + + local ret = {} + local romBoardName = fs.readfile('/tmp/sysinfo/board_name') + + if not romBoardName then + ret.error = 'NO_BOARD_NAME' + return ret + end + + romBoardName = romBoardName:gsub('\n','') + + ret.rom_board_name = romBoardName + + romBoardName = romBoardName:gsub('%p','') + + local p, boardName, n, p1_label, p1_version, p2_label, p2_version, p1_os, p2_os + local current_partition + local op_ubi, cp_info, op_info, zyxelFlagPartition + + p = find_device_data(romBoardName) + + if p 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")) + n, p1_version = p1_label:match('(Linux)-([%d|.]+)') + end + + if p1_label then + if p1_label:find("LEDE") then p1_os = "LEDE" end + if p1_label:find("OpenWrt") then p1_os = "OpenWrt" end + if p.vendorName and p1_label:find(p.vendorName) then p1_os = p.vendorName end + end + + if not p1_os then + p1_os = (p.vendorName and p.vendorName or 'Unknown') .. "/" .. "Unknown" + end + if p1_os and p1_version then p1_os = p1_os .. " (Linux " .. p1_version .. ")" 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")) + n, p2_version = p2_label:match('(Linux)-([%d|.]+)') + end + + if p2_label then + if p2_label:find("LEDE") then p2_os = "LEDE" end + if p2_label:find("OpenWrt") then p2_os = "OpenWrt" end + if p.vendorName and p2_label:find(p.vendorName) then p2_os = p.vendorName end + end + + if not p2_os then + p2_os = (p.vendorName and p.vendorName or 'Unknown') .. "/" .. "Unknown" + end + if p2_os and p2_version then p2_os = p2_os .. " (Linux " .. p2_version .. ")" end + else + p1_os = p.vendorName .. "/" .. "Unknown" .. " (" .. "Compressed" .. ")" + p2_os = p.vendorName .. "/" .. "Unknown" .. " (" .. "Compressed" .. ")" + end + + if p.bootEnv1 then + if fs.access("/usr/sbin/fw_printenv") and fs.access("/usr/sbin/fw_setenv") then + current_partition = tonumber(util.trim(util.exec("fw_printenv -n " .. p.bootEnv1))) + end + else + if not zyxelFlagPartition then zyxelFlagPartition = util.trim(util.exec(". /lib/functions.sh; find_mtd_part 0:DUAL_FLAG")) end + if zyxelFlagPartition then + current_partition = tonumber(util.exec("dd if=" .. zyxelFlagPartition .. " bs=1 count=1 2>/dev/null | hexdump -n 1 -e '1/1 \"%d\"'")) + else + ret.error = 'NO_DUAL_FLAG' + logger("Unable to find Dual Boot Flag Partition.") + return ret + end + end + + ret.current_partition = current_partition + + if is_alt_mountable(p.partition1MTD, p.partition2MTD) then + if current_partition == p.bootEnv1Partition1Value then + op_ubi = tonumber(p.partition2MTD:sub(4)) + 1 + else + op_ubi = tonumber(p.partition1MTD:sub(4)) + 1 + end + local cp_info, op_info = get_partition_os_info(op_ubi) + if current_partition == p.bootEnv1Partition1Value then + p1_os = cp_info or p1_os + p2_os = op_info or p2_os + else + p1_os = op_info or p1_os + p2_os = cp_info or p2_os + end + end + + ret.device_name = (p.vendorName and p.vendorName or "") .. " " .. p.deviceName + + ret.partitions = { + { + os = p1_os, + state = p.bootEnv1Partition1Value == current_partition and 'Current' or 'Alternative', + number = p.bootEnv1Partition1Value + }, + { + os = p2_os, + state = p.bootEnv1Partition2Value == current_partition and 'Current' or 'Alternative', + number = p.bootEnv1Partition2Value + } + } + end + + return ret + end + }, + toggle_boot_partition = { + call = function() + local ret = {} + local zyxelFlagPartition, zyxelBootFlag, zyxelNewBootFlag, errorCode, curEnvSetting, newEnvSetting + + local romBoardName = fs.readfile('/tmp/sysinfo/board_name') + + if not romBoardName then + ret.error = 'NO_BOARD_NAME' + return ret + end + + romBoardName = romBoardName:gsub('\n',''):gsub('%p','') + p = find_device_data(romBoardName) + local bev1, bev2 = p.bootEnv1, p.bootEnv2 + + if bev1 or bev2 then -- Linksys devices + if bev1 then + curEnvSetting = tonumber(util.trim(util.exec("fw_printenv -n " .. bev1))) + if not curEnvSetting then + logger(string.format("Unable to obtain firmware environment variable: %s.", bev1)) + ret.error = 'NO_FIRM_ENV' + ret.args = { bev1 } + return ret + else + local bev1p1, bev1p2 = p.bootEnv1Partition1Value, p.bootEnv1Partition2Value + newEnvSetting = curEnvSetting == bev1p1 and bev1p2 or bev1p1 + errorCode = sys.call("fw_setenv " .. bev1 .. " " .. newEnvSetting) + if errorCode ~= 0 then + logger(string.format("Unable to set firmware environment variable: %s to %s.", bev1, newEnvSetting)) + ret.error = 'ERR_SET_ENV' + ret.args = { bev1, newEnvSetting } + return ret + end + end + end + if bev2 then + curEnvSetting = util.trim(util.exec("fw_printenv -n " .. bev2)) + if not curEnvSetting then + logger(string.format("Unable to obtain firmware environment variable: %s.", bev2)) + ret.error = 'NO_FIRM_ENV' + ret.args = { bev2 } + return ret + else + local bev2p1, bev2p2 = p.bootEnv2Partition1Value, p.bootEnv2Partition1Value + newEnvSetting = curEnvSetting == bev2p1 and bev2p2 or bev2p1 + errorCode = sys.call("fw_setenv " .. bev2 .. " '" .. newEnvSetting .. "'") + if errorCode ~= 0 then + logger(string.format("Unable to set firmware environment variable: %s to %s.", bev2, newEnvSetting)) + ret.error = 'ERR_SET_ENV' + ret.args = { bev2, newEnvSetting } + return ret + end + end + end + else -- NetGear device + if not zyxelFlagPartition then zyxelFlagPartition = util.trim(util.exec(". /lib/functions.sh; find_mtd_part 0:DUAL_FLAG")) end + if not zyxelFlagPartition then + logger("Unable to find Dual Boot Flag Partition.") + ret.error = 'NO_DUAL_FLAG' + else + zyxelBootFlag = tonumber(util.exec("dd if=" .. zyxelFlagPartition .. " bs=1 count=1 2>/dev/null | hexdump -n 1 -e '1/1 \"%d\"'")) + zyxelNewBootFlag = zyxelBootFlag and zyxelBootFlag == 1 and "\\xff" or "\\x01" + if zyxelNewBootFlag then + errorCode = sys.call("printf \"" .. zyxelNewBootFlag .. "\" >" .. zyxelFlagPartition ) + if errorCode ~= 0 then + logger(string.format("Unable to set Dual Boot Flag Partition entry for partition: %s.", zyxelFlagPartition)) + ret.error = 'ERR_SET_DUAL_FLAG' + ret.args = { zyxelFlagPartition } + return ret + end + end + end + end + + return ret + end + } +} + +local function parseInput() + local parse = json.new() + local done, err + + while true do + local chunk = io.read(4096) + if not chunk then + break + elseif not done and not err then + done, err = parse:parse(chunk) + end + end + + if not done then + print(json.stringify({ error = err or "Incomplete input" })) + os.exit(1) + end + + return parse:get() +end + +local function validateArgs(func, uargs) + local method = methods[func] + if not method then + print(json.stringify({ error = "Method not found" })) + os.exit(1) + end + + if type(uargs) ~= "table" then + print(json.stringify({ error = "Invalid arguments" })) + os.exit(1) + end + + uargs.ubus_rpc_session = nil + + local k, v + local margs = method.args or {} + for k, v in pairs(uargs) do + if margs[k] == nil or + (v ~= nil and type(v) ~= type(margs[k])) + then + print(json.stringify({ error = "Invalid arguments" })) + os.exit(1) + end + end + + return method +end + +if arg[1] == "list" then + local _, method, rv = nil, nil, {} + for _, method in pairs(methods) do rv[_] = method.args or {} end + print((json.stringify(rv):gsub(":%[%]", ":{}"))) +elseif arg[1] == "call" then + local args = parseInput() + local method = validateArgs(arg[2], args) + local result, code = method.call(args) + print((json.stringify(result):gsub("^%[%]$", "{}"))) + os.exit(code or 0) +end diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices.disabled/linksys-ea9500.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices.disabled/linksys-ea9500.json new file mode 100644 index 0000000000..7c84413e74 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices.disabled/linksys-ea9500.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "EA9500", + "boardName": "linksys-panamera", + "partition1MTD": "mtd3", + "partition2MTD": "mtd6", + "labelOffset": 28, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": null, + "bootEnv2Partition1Value": null, + "bootEnv2Partition2Value": null +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-e4200v2-ea4500.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-e4200v2-ea4500.json new file mode 100644 index 0000000000..be749a9995 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-e4200v2-ea4500.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "E4200v2/EA4500", + "boardNames": [ "linksys-viper", "linksys,viper" ], + "partition1MTD": "mtd3", + "partition2MTD": "mtd5", + "labelOffset": 32, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": "bootcmd", + "bootEnv2Partition1Value": "run nandboot", + "bootEnv2Partition2Value": "run altnandboot" +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-e4200v2.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-e4200v2.json new file mode 100644 index 0000000000..c32aaf8a3c --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-e4200v2.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "E4200v2", + "boardNames": [ "linksys-e4200v2", "linksys,e4200v2" ], + "partition1MTD": "mtd3", + "partition2MTD": "mtd5", + "labelOffset": 32, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": "bootcmd", + "bootEnv2Partition1Value": "run nandboot", + "bootEnv2Partition2Value": "run altnandboot" +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea3500.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea3500.json new file mode 100644 index 0000000000..6cdc726431 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea3500.json @@ -0,0 +1,15 @@ +{ + "vendorName": "Linksys", + "deviceName": "EA3500", + "boardNames": [ "linksys-audi", "linksys,audi", "linksys-ea3500", "linksys,ea3500" ], + "partition1MTD": "mtd3", + "partition2MTD": "mtd5", + "labelOffset": 32, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": "bootcmd", + "bootEnv2Partition1Value": "run nandboot", + "bootEnv2Partition2Value": "run altnandboot" +} + diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea4500.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea4500.json new file mode 100644 index 0000000000..aa897f8f61 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea4500.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "EA4500", + "boardNames": [ "linksys-e4500", "linksys,e4500" ], + "partition1MTD": "mtd3", + "partition2MTD": "mtd5", + "labelOffset": 32, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": "bootcmd", + "bootEnv2Partition1Value": "run nandboot", + "bootEnv2Partition2Value": "run altnandboot" +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea6350v3.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea6350v3.json new file mode 100644 index 0000000000..f5fc476c10 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea6350v3.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "EA6350v3", + "boardNames": [ "linksys-ea6350v3", "linksys,ea6350v3" ], + "partition1MTD": "mtd10", + "partition2MTD": "mtd12", + "labelOffset": 192, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": null, + "bootEnv2Partition1Value": null, + "bootEnv2Partition2Value": null +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea8300.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea8300.json new file mode 100644 index 0000000000..d4a47886a5 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea8300.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "EA8300", + "boardNames": [ "linksys-ea8300", "linksys,ea8300" ], + "partition1MTD": "mtd10", + "partition2MTD": "mtd12", + "labelOffset": 192, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": null, + "bootEnv2Partition1Value": null, + "bootEnv2Partition2Value": null +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea8500.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea8500.json new file mode 100644 index 0000000000..cafa573fb4 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-ea8500.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "EA8500", + "boardNames": [ "linksys-ea8500", "linksys,ea8500" ], + "partition1MTD": "mtd13", + "partition2MTD": "mtd15", + "labelOffset": 32, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": null, + "bootEnv2Partition1Value": null, + "bootEnv2Partition2Value": null +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-mr8300.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-mr8300.json new file mode 100644 index 0000000000..644f1712f3 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-mr8300.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "MR8300", + "boardNames": [ "linksys-mr8300", "linksys,mr8300" ], + "partition1MTD": "mtd10", + "partition2MTD": "mtd12", + "labelOffset": 192, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": null, + "bootEnv2Partition1Value": null, + "bootEnv2Partition2Value": null +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1200ac.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1200ac.json new file mode 100644 index 0000000000..3d1b19a921 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1200ac.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "WRT1200AC", + "boardNames": [ "linksys-caiman", "linksys,caiman", "linksys,wrt1200ac" ], + "partition1MTD": "mtd4", + "partition2MTD": "mtd6", + "labelOffset": 32, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": "bootcmd", + "bootEnv2Partition1Value": "run nandboot", + "bootEnv2Partition2Value": "run altnandboot" +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1900ac.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1900ac.json new file mode 100644 index 0000000000..d088e9a2ed --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1900ac.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "WRT1900ACv1", + "boardNames": [ "linksys-mamba", "linksys,mamba", "linksys,wrt1900ac-v1" ], + "partition1MTD": "mtd4", + "partition2MTD": "mtd6", + "labelOffset": 32, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": "bootcmd", + "bootEnv2Partition1Value": "run nandboot", + "bootEnv2Partition2Value": "run altnandboot" +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1900acs.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1900acs.json new file mode 100644 index 0000000000..a30b3dcab3 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1900acs.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "WRT1900ACS", + "boardNames": [ "linksys-shelby", "linksys,shelby", "linksys,wrt1900acs" ], + "partition1MTD": "mtd4", + "partition2MTD": "mtd6", + "labelOffset": 32, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": "bootcmd", + "bootEnv2Partition1Value": "run nandboot", + "bootEnv2Partition2Value": "run altnandboot" +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1900acv2.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1900acv2.json new file mode 100644 index 0000000000..361b434b31 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt1900acv2.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "WRT1900ACv2", + "boardNames": [ "linksys-cobra", "linksys,cobra", "linksys,wrt1900ac-v2" ], + "partition1MTD": "mtd4", + "partition2MTD": "mtd6", + "labelOffset": 32, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": "bootcmd", + "bootEnv2Partition1Value": "run nandboot", + "bootEnv2Partition2Value": "run altnandboot" +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt3200acm.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt3200acm.json new file mode 100644 index 0000000000..09fcf96c2b --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt3200acm.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "WRT3200ACM", + "boardNames": [ "linksys-rango", "linksys,rango", "linksys,wrt3200acm" ], + "partition1MTD": "mtd5", + "partition2MTD": "mtd7", + "labelOffset": 32, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": "bootcmd", + "bootEnv2Partition1Value": "run nandboot", + "bootEnv2Partition2Value": "run altnandboot" +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt32x.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt32x.json new file mode 100644 index 0000000000..47e94ab876 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/linksys-wrt32x.json @@ -0,0 +1,14 @@ +{ + "vendorName": "Linksys", + "deviceName": "WRT32X", + "boardNames": [ "linksys-venom", "linksys,venom", "linksys,wrt32x" ], + "partition1MTD": "mtd5", + "partition2MTD": "mtd7", + "labelOffset": null, + "bootEnv1": "boot_part", + "bootEnv1Partition1Value": 1, + "bootEnv1Partition2Value": 2, + "bootEnv2": "bootcmd", + "bootEnv2Partition1Value": "run nandboot", + "bootEnv2Partition2Value": "run altnandboot" +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/zyxel-nbg6817.json b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/zyxel-nbg6817.json new file mode 100644 index 0000000000..719900b066 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/advanced-reboot/devices/zyxel-nbg6817.json @@ -0,0 +1,14 @@ +{ + "vendorName": "ZyXEL", + "deviceName": "NBG6817", + "boardNames": [ "nbg6817" ], + "partition1MTD": "mmcblk0p4", + "partition2MTD": "mmcblk0p7", + "labelOffset": 32, + "bootEnv1": null, + "bootEnv1Partition1Value": 255, + "bootEnv1Partition2Value": 1, + "bootEnv2": null, + "bootEnv2Partition1Value": null, + "bootEnv2Partition2Value": null +} diff --git a/applications/luci-app-advanced-reboot/root/usr/share/luci/menu.d/luci-app-advanced-reboot.json b/applications/luci-app-advanced-reboot/root/usr/share/luci/menu.d/luci-app-advanced-reboot.json new file mode 100644 index 0000000000..e377fa9362 --- /dev/null +++ b/applications/luci-app-advanced-reboot/root/usr/share/luci/menu.d/luci-app-advanced-reboot.json @@ -0,0 +1,13 @@ +{ + "admin/system/advanced_reboot": { + "title": "Advanced Reboot", + "order": 90, + "action": { + "type": "view", + "path": "system/advanced_reboot" + }, + "depends": { + "acl": [ "luci-app-advanced-reboot" ] + } + } +} 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 index 50d50bc2f7..4b22db1083 100644 --- 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 @@ -2,95 +2,14 @@ "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" - ] + "ubus": { + "luci.advanced_reboot": [ "obtain_device_info", "toggle_boot_partition" ] }, - "uci": [ - "network" - ] + "file": { + "/usr/sbin/fw_printenv": [ "list" ], + "/usr/sbin/fw_setenv": [ "list" ], + "/sbin/poweroff": [ "list", "exec" ] + } } } } -- cgit v1.2.3