diff options
author | Hannu Nyman <hannu.nyman@iki.fi> | 2020-10-07 20:25:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-07 20:25:32 +0300 |
commit | 08434255a557a0a49014bda32c9ac6334a6c0c82 (patch) | |
tree | f0ea3f77a9ce8df0a4f01ec9d764b7dfb68a9d94 /applications/luci-app-advanced-reboot/luasrc | |
parent | e06c7b666fbccbf106bfacdf14a540056cd1d29b (diff) | |
parent | feb8d823e59f8c9bf1bdadce6c7fc2a88966f12e (diff) |
Merge pull request #4489 from Ansuel/adanced-client
luci-app-advanced-reboot: convert to client side
Diffstat (limited to 'applications/luci-app-advanced-reboot/luasrc')
21 files changed, 0 insertions, 735 deletions
diff --git a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices.disabled/linksys-ea9500.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices.disabled/linksys-ea9500.lua deleted file mode 100644 index 82f82ddba..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices.disabled/linksys-ea9500.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - vendorName = "Linksys", - deviceName = "EA9500", - boardName = "linksys-panamera", - partition1MTD = "mtd3", - partition2MTD = "mtd6", - labelOffset = 28, - bootEnv1 = "boot_part", - bootEnv1Partition1Value = 1, - bootEnv1Partition2Value = 2, - bootEnv2 = nil, - bootEnv2Partition1Value = nil, - bootEnv2Partition2Value = nil -} diff --git a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-e4200v2-ea4500.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-e4200v2-ea4500.lua deleted file mode 100644 index 6122409dd..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-e4200v2-ea4500.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 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/luasrc/advanced-reboot/devices/linksys-e4200v2.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-e4200v2.lua deleted file mode 100644 index 50c4970ed..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-e4200v2.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 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/luasrc/advanced-reboot/devices/linksys-ea3500.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea3500.lua deleted file mode 100644 index 2b72cd4b7..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea3500.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - 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/luasrc/advanced-reboot/devices/linksys-ea4500.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea4500.lua deleted file mode 100644 index 10f53d1d7..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea4500.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 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/luasrc/advanced-reboot/devices/linksys-ea6350v3.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea6350v3.lua deleted file mode 100644 index ccfe55ead..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea6350v3.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - vendorName = "Linksys", - deviceName = "EA6350v3", - boardNames = { "linksys-ea6350v3", "linksys,ea6350v3" }, - partition1MTD = "mtd10", - partition2MTD = "mtd12", - labelOffset = 192, - bootEnv1 = "boot_part", - bootEnv1Partition1Value = 1, - bootEnv1Partition2Value = 2, - bootEnv2 = nil, - bootEnv2Partition1Value = nil, - bootEnv2Partition2Value = nil -} diff --git a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea8300.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea8300.lua deleted file mode 100644 index e5faf2787..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea8300.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - vendorName = "Linksys", - deviceName = "EA8300", - boardNames = { "linksys-ea8300", "linksys,ea8300" }, - partition1MTD = "mtd10", - partition2MTD = "mtd12", - labelOffset = 192, - bootEnv1 = "boot_part", - bootEnv1Partition1Value = 1, - bootEnv1Partition2Value = 2, - bootEnv2 = nil, - bootEnv2Partition1Value = nil, - bootEnv2Partition2Value = nil -} diff --git a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea8500.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea8500.lua deleted file mode 100644 index 865b72683..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-ea8500.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - vendorName = "Linksys", - deviceName = "EA8500", - boardNames = { "linksys-ea8500", "linksys,ea8500" }, - partition1MTD = "mtd13", - partition2MTD = "mtd15", - labelOffset = 32, - bootEnv1 = "boot_part", - bootEnv1Partition1Value = 1, - bootEnv1Partition2Value = 2, - bootEnv2 = nil, - bootEnv2Partition1Value = nil, - bootEnv2Partition2Value = nil -} diff --git a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-mr8300.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-mr8300.lua deleted file mode 100644 index 49b3086db..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-mr8300.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - vendorName = "Linksys", - deviceName = "MR8300", - boardNames = { "linksys-mr8300", "linksys,mr8300" }, - partition1MTD = "mtd10", - partition2MTD = "mtd12", - labelOffset = 192, - bootEnv1 = "boot_part", - bootEnv1Partition1Value = 1, - bootEnv1Partition2Value = 2, - bootEnv2 = nil, - bootEnv2Partition1Value = nil, - bootEnv2Partition2Value = nil -} diff --git a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1200ac.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1200ac.lua deleted file mode 100644 index a3efb6973..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1200ac.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 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/luasrc/advanced-reboot/devices/linksys-wrt1900ac.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1900ac.lua deleted file mode 100644 index 24869bef8..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1900ac.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 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/luasrc/advanced-reboot/devices/linksys-wrt1900acs.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1900acs.lua deleted file mode 100644 index 6b409a191..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1900acs.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 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/luasrc/advanced-reboot/devices/linksys-wrt1900acv2.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1900acv2.lua deleted file mode 100644 index 15062eb54..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt1900acv2.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 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/luasrc/advanced-reboot/devices/linksys-wrt3200acm.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt3200acm.lua deleted file mode 100644 index 2e4cbec1a..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt3200acm.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 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/luasrc/advanced-reboot/devices/linksys-wrt32x.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt32x.lua deleted file mode 100644 index dd9baf551..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/linksys-wrt32x.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - vendorName = "Linksys", - deviceName = "WRT32X", - boardNames = { "linksys-venom", "linksys,venom", "linksys,wrt32x" }, - partition1MTD = "mtd5", - partition2MTD = "mtd7", - labelOffset = nil, - bootEnv1 = "boot_part", - bootEnv1Partition1Value = 1, - bootEnv1Partition2Value = 2, - bootEnv2 = "bootcmd", - bootEnv2Partition1Value = "run nandboot", - bootEnv2Partition2Value = "run altnandboot" -} diff --git a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/zyxel-nbg6817.lua b/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/zyxel-nbg6817.lua deleted file mode 100644 index 0e9112472..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/advanced-reboot/devices/zyxel-nbg6817.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - vendorName = "ZyXEL", - deviceName = "NBG6817", - boardNames = { "nbg6817" }, - partition1MTD = "mmcblk0p4", - partition2MTD = "mmcblk0p7", - labelOffset = 32, - bootEnv1 = nil, - bootEnv1Partition1Value = 255, - bootEnv1Partition2Value = 1, - bootEnv2 = nil, - bootEnv2Partition1Value = nil, - bootEnv2Partition2Value = nil -} diff --git a/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua b/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua deleted file mode 100644 index 1fb4d461b..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua +++ /dev/null @@ -1,303 +0,0 @@ --- 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) - -local util = require "luci.util" -local fs = require "nixio.fs" -local sys = require "luci.sys" -local http = require "luci.http" -local dispatcher = require "luci.dispatcher" -local i18n = require "luci.i18n" -local ltemplate = require "luci.template" -local ip = require "luci.ip" -local http = require "luci.http" -local sys = require "luci.sys" -local dispatcher = require "luci.dispatcher" -local uci = require "luci.model.uci".cursor() -local packageName = "advanced-reboot" -local devices_dir = "/usr/lib/lua/luci/" .. packageName .. "/devices/" - -function logger(t) - util.exec("logger -t " .. packageName .. " '" .. tostring(t) .. "'") -end - -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 - -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(i18n.translatef("attempting to mount alternative partition (mtd%s)", tostring(op_ubi))) - alt_partition_unmount(op_ubi) - alt_partition_mount(op_ubi) - if fs.access("/alt/rom/etc/os-release") then - op_info = util.trim(util.exec('. /alt/rom/etc/os-release && echo "$PRETTY_NAME"')) - if op_info:find("SNAPSHOT") then - op_info = util.trim(util.exec('. /alt/rom/etc/os-release && echo "$OPENWRT_RELEASE"')) - end - end - logger(i18n.translatef("attempting to unmount alternative partition (mtd%s)", tostring(op_ubi))) - alt_partition_unmount(op_ubi) - return cp_info, op_info -end - -function alt_partition_mount(op_ubi) - local ubi_dev - util.exec('for i in rom 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/rom") - util.exec("mount -t ubifs /dev/ubi" .. ubi_dev .. "_1 /alt/overlay") --- util.exec("mount -t overlay overlay -o noatime,lowerdir=/alt/rom,upperdir=/alt/overlay/upper,workdir=/alt/overlay/work /alt/firmware") -end - -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/overlay ] && umount /alt/overlay") - util.exec("[ -d /alt/rom ] && umount /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 - -function obtain_device_info() - local p, boardName, n, p1_label, p1_version, p2_label, p2_version, p1_os, p2_os - local errorMessage, current_partition - local op_ubi, cp_info, op_info, zyxelFlagPartition - local romBoardName = util.trim(util.exec("cat /tmp/sysinfo/board_name")) - for filename in fs.dir(devices_dir) do - local p_func = loadfile(devices_dir .. filename) - setfenv(p_func, { _ = i18n.translate }) - p = p_func() - 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")) - 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")) - n, p2_version = p2_label:match('(Linux)-([%d|.]+)') - end - if p1_label and p1_label:find("LEDE") then p1_os = "LEDE" end - if p1_label and p1_label:find("OpenWrt") then p1_os = "OpenWrt" end - if p1_label and p.vendorName and p1_label:find(p.vendorName) then p1_os = p.vendorName end - if p2_label and p2_label:find("LEDE") then p2_os = "LEDE" end - if p2_label and p2_label:find("OpenWrt") then p2_os = "OpenWrt" end - if p2_label and p.vendorName and p2_label:find(p.vendorName) then p2_os = p.vendorName end - if not p1_os then p1_os = p.vendorName .. "/" .. i18n.translate("Unknown") end - if not p2_os then p2_os = p.vendorName .. "/" .. i18n.translate("Unknown") end - if p1_os and p1_version then p1_os = p1_os .. " (Linux " .. p1_version .. ")" end - if p2_os and p2_version then p2_os = p2_os .. " (Linux " .. p2_version .. ")" end - else - p1_os = p.vendorName .. "/" .. i18n.translate("Unknown") .. " (" .. i18n.translate("Compressed") .. ")" - p2_os = p.vendorName .. "/" .. i18n.translate("Unknown") .. " (" .. i18n.translate("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 - errorMessage = errorMessage or i18n.translate("Unable to find Dual Boot Flag Partition.") - util.perror(i18n.translate("Unable to find Dual Boot Flag Partition.")) - end - end - - 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 - return romBoardName, p.vendorName .. " " .. p.deviceName, p.bootEnv1, p.bootEnv1Partition1Value, p1_os, p.bootEnv1Partition2Value, p2_os, p.bootEnv2, p.bootEnv2Partition1Value, p.bootEnv2Partition1Value, current_partition - end - end - return romBoardName, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil -end - -function index() - 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")) -end - -function action_template() - local romBoardName, device_name, bev1, bev1p1, p1_os, bev1p2, p2_os, bev2, bev2p1, bev2p2, current_partition = obtain_device_info() - ltemplate.render("advanced_reboot/advanced_reboot",{ - romBoardName=romBoardName, - device_name=device_name, - bev1p1=bev1p1, - p1_os=p1_os, - bev1p2=bev1p2, - p2_os=p2_os, - current_partition=current_partition, - errorMessage=errorMessage}) -end - -function action_reboot() - ltemplate.render("advanced_reboot/applyreboot", { - title = i18n.translate("Rebooting..."), - msg = i18n.translate("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 address of your computer to reach the device again, depending on your settings."), - addr = ip.new(util.imatch(uci:get("network", "lan", "ipaddr"))() or "192.168.1.1") - }) - sys.reboot() -end - -function action_altreboot() - local romBoardName, device_name, bev1, bev1p1, p1_os, bev1p2, p2_os, bev2, bev2p1, bev2p2, current_partition = obtain_device_info() - local zyxelFlagPartition, zyxelBootFlag, zyxelNewBootFlag, errorCode, curEnvSetting, newEnvSetting - errorMessage = nil - errorCode = 0 - if http.formvalue("cancel") then - http.redirect(dispatcher.build_url('admin/system/advanced_reboot')) - return - end - local step = tonumber(http.formvalue("step") or 1) - if step == 1 then - if fs.access("/usr/sbin/fw_printenv") and fs.access("/usr/sbin/fw_setenv") then - ltemplate.render("advanced_reboot/alternative_reboot",{}) - else - ltemplate.render("advanced_reboot/advanced_reboot",{errorMessage = i18n.translate("No access to fw_printenv or fw_printenv!")}) - end - elseif step == 2 then - if bev1 or bev2 then -- Linksys devices - if bev1 then - curEnvSetting = tonumber(util.trim(util.exec("fw_printenv -n " .. bev1))) - if not curEnvSetting then - errorMessage = errorMessage .. i18n.translatef("Unable to obtain firmware environment variable: %s.", bev1) - util.perror(i18n.translatef("Unable to obtain firmware environment variable: %s.", bev1)) - else - newEnvSetting = curEnvSetting == bev1p1 and bev1p2 or bev1p1 - errorCode = sys.call("fw_setenv " .. bev1 .. " " .. newEnvSetting) - if errorCode ~= 0 then - errorMessage = errorMessage or "" .. i18n.translatef("Unable to set firmware environment variable: %s to %s.", bev1, newEnvSetting) - util.perror(i18n.translatef("Unable to set firmware environment variable: %s to %s.", bev1, newEnvSetting)) - end - end - end - if bev2 then - curEnvSetting = util.trim(util.exec("fw_printenv -n " .. bev2)) - if not curEnvSetting then - errorMessage = errorMessage or "" .. i18n.translatef("Unable to obtain firmware environment variable: %s.", bev2) - util.perror(i18n.translatef("Unable to obtain firmware environment variable: %s.", bev2)) - else - newEnvSetting = curEnvSetting == bev2p1 and bev2p2 or bev2p1 - errorCode = sys.call("fw_setenv " .. bev2 .. " '" .. newEnvSetting .. "'") - if errorCode ~= 0 then - errorMessage = errorMessage or "" .. i18n.translatef("Unable to set firmware environment variable: %s to %s.", bev2, newEnvSetting) - util.perror(i18n.translatef("Unable to set firmware environment variable: %s to %s.", bev2, newEnvSetting)) - 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 - errorMessage = errorMessage .. i18n.translate("Unable to find Dual Boot Flag Partition." .. " ") - util.perror(i18n.translate("Unable to find Dual Boot Flag Partition.")) - 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 - errorMessage = errorMessage or "" .. i18n.translatef("Unable to set Dual Boot Flag Partition entry for partition: %s.", zyxelFlagPartition) - util.perror(i18n.translatef("Unable to set Dual Boot Flag Partition entry for partition: %s.", zyxelFlagPartition)) - end - end - end - end - if not errorMessage then - ltemplate.render("advanced_reboot/applyreboot", { - title = i18n.translate("Rebooting..."), - msg = i18n.translate("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 might be necessary to renew the address of your computer to reach the device again, depending on your settings."), - addr = ip.new(util.imatch(uci:get("network", "lan", "ipaddr"))() or "192.168.1.1") - }) - sys.reboot() - else - ltemplate.render("advanced_reboot/advanced_reboot",{ - romBoardName=romBoardName, - device_name=device_name, - bev1p1=bev1p1, - p1_os=p1_os, - bev1p2=bev1p2, - p2_os=p2_os, - current_partition=current_partition, - errorMessage = errorMessage}) - end - end -end - -function action_poweroff() - if http.formvalue("cancel") then - http.redirect(dispatcher.build_url('admin/system/advanced_reboot')) - return - end - local step = tonumber(http.formvalue("step") or 1) - if step == 1 then - if fs.access("/sbin/poweroff") then - ltemplate.render("advanced_reboot/power_off",{}) - else - ltemplate.render("advanced_reboot/advanced_reboot",{}) - end - elseif step == 2 then - ltemplate.render("advanced_reboot/applyreboot", { - title = i18n.translate("Shutting down..."), - msg = i18n.translate("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."), - addr = ip.new(util.imatch(uci:get("network", "lan", "ipaddr"))() or "192.168.1.1") - }) - sys.call("/sbin/poweroff") - end -end diff --git a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/advanced_reboot.htm b/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/advanced_reboot.htm deleted file mode 100644 index a28418cc5..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/advanced_reboot.htm +++ /dev/null @@ -1,100 +0,0 @@ -<%# - Copyright 2008 Steven Barth <steven@midlink.org> - Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org> - Copyright 2017-2020 Stan Grishin <stangri@melmac.net> - Licensed to the public under the Apache License 2.0. --%> - -<%+header%> - -<h2 name="content"><%:Advanced Reboot%></h2> -<br /> - -<%- local c = require("luci.model.uci").cursor():changes(); if c and next(c) then -%> - <p class="alert-message warning"><%:Warning: There are unsaved changes that will get lost on reboot!%></p> -<%- end -%> - -<%- if errorMessage and errorMessage ~= "" then -%> - <p class="alert-message warning"><%:ERROR: %><%=errorMessage%></p> -<%- end -%> - -<%- if device_name then -%> -<fieldset class="cbi-section"> - <legend><%=device_name%><%: Partitions%></legend> - <div class="table cbi-section-table" id="partitions"> - <div class="tr cbi-section-table-titles"> - <div class="th cbi-section-table-cell"><%:Partition%></div> - <div class="th cbi-section-table-cell"><%:Status%></div> - <div class="th cbi-section-table-cell"><%:Firmware%></div> - <div class="th cbi-section-table-cell"><%:Reboot%></div> - </div> - <div class="tr cbi-section-table-row cbi-rowstyle-<%- if bev1p1 == current_partition then -%><%=1%><%- else -%><%=2%><%- end -%>"> - <div class="td"> - <%=string.format("%X", bev1p1)%> - </div> - <div class="td"> - <%- if bev1p1 == current_partition then -%><%:Current%><%- else -%><%:Alternative%><%- end -%> - </div> - <div class="td"> - <%=p1_os%> - </div> - <div class="td"> - <%- if bev1p1 == current_partition then -%> - <form method="post" action="<%=url('admin/system/advanced_reboot/reboot')%>"> - <input type="hidden" name="token" value="<%=token%>" /> - <input id="reboot-button" type="submit" class="btn cbi-button cbi-button-apply important" value="<%:Reboot to current partition%>" /> - </form> - <%- else -%> - <form method="post" action="<%=url('admin/system/advanced_reboot/alternative_reboot')%>"> - <input type="hidden" name="token" value="<%=token%>" /> - <input id="altreboot-button" type="submit" class="btn cbi-button cbi-button-apply important" value="<%:Reboot to alternative partition...%>" /> - </form> - <%- end -%> - </div> - </div> - <div class="tr cbi-section-table-row cbi-rowstyle-<%- if bev1p2 == current_partition then -%><%=1%><%- else -%><%=2%><%- end -%>"> - <div class="td"> - <%=string.format("%X", bev1p2)%> - </div> - <div class="td"> - <%- if bev1p2 == current_partition then -%><%:Current%><%- else -%><%:Alternative%><%- end -%> - </div> - <div class="td"> - <%=p2_os%> - </div> - <div class="td"> - <%- if bev1p2 == current_partition then -%> - <form method="post" action="<%=url('admin/system/advanced_reboot/reboot')%>"> - <input type="hidden" name="token" value="<%=token%>" /> - <input id="reboot-button" type="submit" class="btn cbi-button cbi-button-apply important" value="<%:Reboot to current partition%>" /> - </form> - <%- else -%> - <form method="post" action="<%=url('admin/system/advanced_reboot/alternative_reboot')%>"> - <input type="hidden" name="token" value="<%=token%>" /> - <input id="altreboot-button" type="submit" class="btn cbi-button cbi-button-apply important" value="<%:Reboot to alternative partition...%>" /> - </form> - <%- end -%> - </div> - </div> - </div> -</fieldset> -<%- else -%> - <%- if rom_board_name then -%> - <p class="alert-message warning"><%=pcdata(translatef("Warning: Device (%s) is unknown or isn't a dual-partition device!", rom_board_name))%></p> - <%- else -%> - <p class="alert-message warning"><%=pcdata(translatef("Warning: Unable to obtain device information!"))%></p> - <%- end -%> -<%- end -%> - -<hr /> - -<%- if nixio.fs.access("/sbin/poweroff") then -%> -<form method="post" action="<%=url('admin/system/advanced_reboot/power_off')%>"> - <input type="hidden" name="token" value="<%=token%>" /> - <input id="poweroff-button" type="submit" class="btn cbi-button cbi-button-apply important" value="<%:Perform power off...%>" /> -</form> -<%- else -%> - <p class="alert-message warning"><%:Warning: This system does not support powering off!%></p> -<%- end -%> - -<%+footer%> diff --git a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/alternative_reboot.htm b/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/alternative_reboot.htm deleted file mode 100644 index b81aaf455..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/alternative_reboot.htm +++ /dev/null @@ -1,29 +0,0 @@ -<%# - Copyright 2008 Steven Barth <steven@midlink.org> - Copyright 2008-2009 Jo-Philipp Wich <jow@openwrt.org> - Copyright 2017-2018 Stan Grishin <stangri@melmac.net> - Licensed to the public under the Apache License 2.0. --%> - -<%+header%> - -<h2 name="content"><%:Reboot Device to an Alternative Partition%> - <%:Confirm%></h2> -<p> - <%_ WARNING: An alternative partition might have its own settings and completely different firmware.<br /><br /> - As your network configuration and WiFi SSID/password on alternative partition might be different, - you might have to adjust your computer settings to be able to access your device once it reboots.<br /><br /> - Please also be aware that alternative partition firmware might not provide an easy way to switch active partition - and boot back to the currently active partition.<br /><br /> - Click "Proceed" below to reboot device to an alternative partition. %> -</p> - -<div class="cbi-page-actions right"> - <form class="inline" action="<%=REQUEST_URI%>" method="post"> - <input type="hidden" name="token" value="<%=token%>" /> - <input type="hidden" name="step" value="2" /> - <input class="btn cbi-button cbi-button-reset important" name="cancel" type="submit" value="<%:Cancel%>" /> - <input class="btn cbi-button cbi-button-apply important" type="submit" value="<%:Proceed%>" /> - </form> -</div> - -<%+footer%> diff --git a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/applyreboot.htm b/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/applyreboot.htm deleted file mode 100644 index 94ac36bd7..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/applyreboot.htm +++ /dev/null @@ -1,53 +0,0 @@ -<%# - Copyright 2008 Steven Barth <steven@midlink.org> - Copyright 2008 Jo-Philipp Wich <jow@openwrt.org> - Licensed to the public under the Apache License 2.0. --%> - -<html> - <head> - <title><%=luci.sys.hostname()%> - <%= title or translate("Rebooting...") %></title> - <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css?v=git-19.271.68204-f8775ee" /> - <script type="text/javascript" src="<%=resource%>/xhr.js?v=git-19.271.68204-f8775ee"></script> - <script type="text/javascript">//<![CDATA[ - var interval = window.setInterval(function() { - var img = new Image(); - var target = ('https:' == document.location.protocol ? 'https://' : 'http://') + <%=addr and "'%s'" % addr or "window.location.host"%>; - - img.onload = function() { - window.clearInterval(interval); - window.location.replace(target); - }; - - img.src = target + '<%=resource%>/icons/loading.gif?' + Math.random(); - - }, 5000); - //]]></script> - </head> - <body> - <header> - <div class="fill"> - <div class="container"> - <p class="brand"><%=luci.sys.hostname() or "?"%></p> - </div> - </div> - </header> -   - <div class="main"> - <div id="maincontainer"> - <div id="maincontent" class="container"> - <h2 name="content" id="applyreboot-container" ><%:System%> - <%= title or translate("Rebooting...") %></h2> - <div class="cbi-section" id="applyreboot-section"> - <div> - <%= msg or translate("Changes applied.") %> - </div> - <div> - <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> - <%:Waiting for changes to be applied...%> - </div> - </div> - </div> - </div> - </div> - </body> -</html>
\ No newline at end of file diff --git a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/power_off.htm b/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/power_off.htm deleted file mode 100644 index 56200a4c1..000000000 --- a/applications/luci-app-advanced-reboot/luasrc/view/advanced_reboot/power_off.htm +++ /dev/null @@ -1,25 +0,0 @@ -<%# - Copyright 2008 Steven Barth <steven@midlink.org> - Copyright 2008-2009 Jo-Philipp Wich <jow@openwrt.org> - Copyright 2017-2018 Stan Grishin <stangri@melmac.net> - Licensed to the public under the Apache License 2.0. --%> - -<%+header%> - -<h2 name="content"><%:Power Off Device%> - <%:Confirm%></h2> -<p> - <%_ WARNING: Power off might result in a reboot on a device which doesn't support power off.<br /><br /> - Click "Proceed" below to power off your device. %> -</p> - -<div class="cbi-page-actions right"> - <form class="inline" action="<%=REQUEST_URI%>" method="post"> - <input type="hidden" name="token" value="<%=token%>" /> - <input type="hidden" name="step" value="2" /> - <input class="btn cbi-button cbi-button-reset important" name="cancel" type="submit" value="<%:Cancel%>" /> - <input class="btn cbi-button cbi-button-apply important" type="submit" value="<%:Proceed%>" /> - </form> -</div> - -<%+footer%> |