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 <jo@mein.io>
This commit is contained in:
parent
75ac400168
commit
1104b837cd
1 changed files with 6 additions and 5 deletions
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
module("luci.controller.advanced_reboot", package.seeall)
|
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
|
-- 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 = {
|
devices = {
|
||||||
{"Linksys EA3500", "linksys-audi", "mtd3", "mtd5", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
|
{"Linksys EA3500", "linksys-audi", "mtd3", "mtd5", 32, "boot_part", 1, 2, "bootcmd", "run nandboot", "run altnandboot"},
|
||||||
|
@ -83,15 +81,17 @@ function index()
|
||||||
end
|
end
|
||||||
|
|
||||||
function action_reboot()
|
function action_reboot()
|
||||||
|
local uci = require "luci.model.uci".cursor()
|
||||||
luci.template.render("admin_system/applyreboot", {
|
luci.template.render("admin_system/applyreboot", {
|
||||||
title = luci.i18n.translate("Rebooting..."),
|
title = luci.i18n.translate("Rebooting..."),
|
||||||
msg = luci.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."),
|
msg = luci.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 = 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()
|
luci.sys.reboot()
|
||||||
end
|
end
|
||||||
|
|
||||||
function action_altreboot()
|
function action_altreboot()
|
||||||
|
local uci = require "luci.model.uci".cursor()
|
||||||
local zyxelFlagPartition, zyxelBootFlag, zyxelNewBootFlag, errorCode, curEnvSetting, newEnvSetting
|
local zyxelFlagPartition, zyxelBootFlag, zyxelNewBootFlag, errorCode, curEnvSetting, newEnvSetting
|
||||||
errorMessage = ""
|
errorMessage = ""
|
||||||
errorCode = 0
|
errorCode = 0
|
||||||
|
@ -165,7 +165,7 @@ function action_altreboot()
|
||||||
luci.template.render("admin_system/applyreboot", {
|
luci.template.render("admin_system/applyreboot", {
|
||||||
title = luci.i18n.translate("Rebooting..."),
|
title = luci.i18n.translate("Rebooting..."),
|
||||||
msg = luci.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."),
|
msg = luci.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 = 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()
|
luci.sys.reboot()
|
||||||
else
|
else
|
||||||
|
@ -182,6 +182,7 @@ function action_altreboot()
|
||||||
end
|
end
|
||||||
|
|
||||||
function action_poweroff()
|
function action_poweroff()
|
||||||
|
local uci = require "luci.model.uci".cursor()
|
||||||
if luci.http.formvalue("cancel") then
|
if luci.http.formvalue("cancel") then
|
||||||
luci.http.redirect(luci.dispatcher.build_url('admin/system/advanced_reboot'))
|
luci.http.redirect(luci.dispatcher.build_url('admin/system/advanced_reboot'))
|
||||||
return
|
return
|
||||||
|
@ -197,7 +198,7 @@ function action_poweroff()
|
||||||
luci.template.render("admin_system/applyreboot", {
|
luci.template.render("admin_system/applyreboot", {
|
||||||
title = luci.i18n.translate("Shutting down..."),
|
title = luci.i18n.translate("Shutting down..."),
|
||||||
msg = luci.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."),
|
msg = luci.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 = 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")
|
luci.sys.call("/sbin/poweroff")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue