Skip to content
Snippets Groups Projects
Unverified Commit 97879e80 authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

gluon-config-mode-core: clean up reboot handling

Don't fork reboot process before all package hooks have been handled and
rendering is complete.

Replace debug.setfenv hack to close stdout with nixio.dup.

Fixes #772
parent 4a60e5a0
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,6 @@ function action_reboot() ...@@ -48,7 +48,6 @@ function action_reboot()
uci:save("gluon-setup-mode") uci:save("gluon-setup-mode")
uci:commit("gluon-setup-mode") uci:commit("gluon-setup-mode")
if nixio.fork() ~= 0 then
local fs = require "nixio.fs" local fs = require "nixio.fs"
local util = require "nixio.util" local util = require "nixio.util"
...@@ -70,21 +69,21 @@ function action_reboot() ...@@ -70,21 +69,21 @@ function action_reboot()
local hostname = uci:get_first("system", "system", "hostname") local hostname = uci:get_first("system", "system", "hostname")
luci.template.render("gluon/config-mode/reboot", { parts=parts luci.template.render("gluon/config-mode/reboot",
, hostname=hostname {
}) parts = parts,
else hostname = hostname,
debug.setfenv(io.stdout, debug.getfenv(io.open '/dev/null')) }
io.stdout:close() )
if nixio.fork() == 0 then
-- Replace stdout with /dev/null
nixio.dup(nixio.open('/dev/null', 'w'), nixio.stdout)
-- Sleep a little so the browser can fetch everything required to -- Sleep a little so the browser can fetch everything required to
-- display the reboot page, then reboot the device. -- display the reboot page, then reboot the device.
nixio.nanosleep(2) nixio.nanosleep(1)
-- Run reboot with popen so it gets its own std filehandles.
io.popen("reboot")
-- Prevent any further execution in this child. nixio.execp("reboot")
os.exit()
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment