From 1104b837cdf87e42512a32c48c9bedbd9c1d6d57 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 7 Apr 2018 14:42:29 +0200 Subject: luci-app-advanced-reboot: remove explicit libuci requirement Rewrite affected code to use luci.model.uci in order to avoid the need for using libuci-lua directly. Signed-off-by: Jo-Philipp Wich --- .../luasrc/controller/advanced_reboot.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'applications/luci-app-advanced-reboot') diff --git a/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua b/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua index 8c540521d..b5dd4fe0f 100644 --- a/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua +++ b/applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua @@ -3,8 +3,6 @@ module("luci.controller.advanced_reboot", package.seeall) -uci = require "uci" - -- device_name, board_name, part1, part2, offset, env_var_1, value_1_1, value_1_2, env_var_2, value_2_1, value_2_2 devices = { {"Linksys EA3500", "linksys-audi", "mtd3", "mtd5", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"}, @@ -83,15 +81,17 @@ function index() end function action_reboot() + local uci = require "luci.model.uci".cursor() luci.template.render("admin_system/applyreboot", { title = luci.i18n.translate("Rebooting..."), msg = luci.i18n.translate("The system is rebooting now.
DO NOT POWER OFF THE DEVICE!
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 = luci.ip.new(uci.cursor():get("network", "lan", "ipaddr")) or "192.168.1.1" + addr = luci.ip.new(uci:get("network", "lan", "ipaddr")) or "192.168.1.1" }) luci.sys.reboot() end function action_altreboot() + local uci = require "luci.model.uci".cursor() local zyxelFlagPartition, zyxelBootFlag, zyxelNewBootFlag, errorCode, curEnvSetting, newEnvSetting errorMessage = "" errorCode = 0 @@ -165,7 +165,7 @@ function action_altreboot() luci.template.render("admin_system/applyreboot", { title = luci.i18n.translate("Rebooting..."), msg = luci.i18n.translate("The system is rebooting to an alternative partition now.
DO NOT POWER OFF THE DEVICE!
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 = luci.ip.new(uci.cursor():get("network", "lan", "ipaddr")) or "192.168.1.1" + addr = luci.ip.new(uci:get("network", "lan", "ipaddr")) or "192.168.1.1" }) luci.sys.reboot() else @@ -182,6 +182,7 @@ function action_altreboot() end function action_poweroff() + local uci = require "luci.model.uci".cursor() if luci.http.formvalue("cancel") then luci.http.redirect(luci.dispatcher.build_url('admin/system/advanced_reboot')) return @@ -197,7 +198,7 @@ function action_poweroff() luci.template.render("admin_system/applyreboot", { title = luci.i18n.translate("Shutting down..."), msg = luci.i18n.translate("The system is shutting down now.
DO NOT POWER OFF THE DEVICE!
It might be necessary to renew the address of your computer to reach the device again, depending on your settings."), - addr = luci.ip.new(uci.cursor():get("network", "lan", "ipaddr")) or "192.168.1.1" + addr = luci.ip.new(uci:get("network", "lan", "ipaddr")) or "192.168.1.1" }) luci.sys.call("/sbin/poweroff") end -- cgit v1.2.3