gluon-config-mode-*: replace nixio with gluon.util
This commit is contained in:
parent
90031ba97a
commit
92d90cdfb7
@ -1,19 +1,12 @@
|
||||
<h2><%:Your node's setup is now complete.%></h2>
|
||||
<%
|
||||
local fs = require "nixio.fs"
|
||||
local util = require "nixio.util"
|
||||
|
||||
local parts_dir = "/lib/gluon/config-mode/reboot/"
|
||||
local files = util.consume(fs.dir(parts_dir) or function() end)
|
||||
table.sort(files)
|
||||
local util = require "gluon.util"
|
||||
|
||||
local parts = {}
|
||||
for _, entry in ipairs(files) do
|
||||
if entry:sub(1, 1) ~= '.' then
|
||||
local p = assert(loadfile(parts_dir .. entry))
|
||||
setfenv(p, getfenv())
|
||||
table.insert(parts, p)
|
||||
end
|
||||
for _, entry in ipairs(util.glob('/lib/gluon/config-mode/reboot/*')) do
|
||||
local p = assert(loadfile(entry))
|
||||
setfenv(p, getfenv())
|
||||
table.insert(parts, p)
|
||||
end
|
||||
|
||||
for _, p in ipairs(parts) do
|
||||
|
@ -1,22 +1,13 @@
|
||||
local fs = require "nixio.fs"
|
||||
local util = require "gluon.util"
|
||||
local nixio_util = require "nixio.util"
|
||||
|
||||
local uci = require("simple-uci").cursor()
|
||||
|
||||
local wizard_dir = "/lib/gluon/config-mode/wizard/"
|
||||
|
||||
local files = nixio_util.consume(fs.dir(wizard_dir) or function() end)
|
||||
table.sort(files)
|
||||
|
||||
local wizard = {}
|
||||
for _, entry in ipairs(files) do
|
||||
if entry:sub(1, 1) ~= '.' then
|
||||
local f = assert(loadfile(wizard_dir .. entry))
|
||||
setfenv(f, getfenv())
|
||||
local w = f()
|
||||
table.insert(wizard, w)
|
||||
end
|
||||
for _, entry in ipairs(util.glob('/lib/gluon/config-mode/wizard/*')) do
|
||||
local f = assert(loadfile(entry))
|
||||
setfenv(f, getfenv())
|
||||
local w = f()
|
||||
table.insert(wizard, w)
|
||||
end
|
||||
|
||||
local f = Form(translate("Welcome!"))
|
||||
@ -45,7 +36,8 @@ for _, w in ipairs(wizard) do
|
||||
end
|
||||
|
||||
function f:write()
|
||||
local nixio = require "nixio"
|
||||
local fcntl = require 'posix.fcntl'
|
||||
local unistd = require 'posix.unistd'
|
||||
|
||||
uci:set("gluon-setup-mode", uci:get_first("gluon-setup-mode", "setup_mode"), "configured", true)
|
||||
|
||||
@ -60,15 +52,16 @@ function f:write()
|
||||
f.package = "gluon-config-mode-core"
|
||||
f.hidenav = true
|
||||
|
||||
if nixio.fork() == 0 then
|
||||
if unistd.fork() == 0 then
|
||||
-- Replace stdout with /dev/null
|
||||
nixio.dup(nixio.open('/dev/null', 'w'), nixio.stdout)
|
||||
local null = fcntl.open('/dev/null', fcntl.O_WRONLY)
|
||||
unistd.dup2(null, unistd.STDOUT_FILENO)
|
||||
|
||||
-- Sleep a little so the browser can fetch everything required to
|
||||
-- display the reboot page, then reboot the device.
|
||||
nixio.nanosleep(1)
|
||||
unistd.sleep(1)
|
||||
|
||||
nixio.execp("reboot")
|
||||
unistd.execp('reboot', {[0] = 'reboot'})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
return function(form, uci)
|
||||
local site_i18n = i18n 'gluon-site'
|
||||
|
||||
local fs = require 'nixio.fs'
|
||||
local json = require 'jsonc'
|
||||
local site = require 'gluon.site'
|
||||
local util = require 'gluon.util'
|
||||
@ -22,7 +21,7 @@ return function(form, uci)
|
||||
|
||||
local function get_domain_list()
|
||||
local list = {}
|
||||
for domain_path in fs.glob('/lib/gluon/domains/*.json') do
|
||||
for _, domain_path in ipairs(util.glob('/lib/gluon/domains/*.json')) do
|
||||
local domain_code = domain_path:match('([^/]+)%.json$')
|
||||
local domain = assert(json.load(domain_path))
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
local site_i18n = i18n 'gluon-site'
|
||||
|
||||
local uci = require("simple-uci").cursor()
|
||||
local fs = require "nixio.fs"
|
||||
local unistd = require 'posix.unistd'
|
||||
|
||||
local platform = require 'gluon.platform'
|
||||
local site = require 'gluon.site'
|
||||
@ -11,8 +11,8 @@ local util = require "gluon.util"
|
||||
local pretty_hostname = require 'pretty_hostname'
|
||||
|
||||
|
||||
local has_fastd = fs.access('/lib/gluon/mesh-vpn/fastd')
|
||||
local has_tunneldigger = fs.access('/lib/gluon/mesh-vpn/tunneldigger')
|
||||
local has_fastd = unistd.access('/lib/gluon/mesh-vpn/fastd')
|
||||
local has_tunneldigger = unistd.access('/lib/gluon/mesh-vpn/tunneldigger')
|
||||
|
||||
|
||||
local hostname = pretty_hostname.get(uci)
|
||||
|
@ -1,7 +1,7 @@
|
||||
local fs = require "nixio.fs"
|
||||
local unistd = require 'posix.unistd'
|
||||
|
||||
local has_fastd = fs.access('/lib/gluon/mesh-vpn/fastd')
|
||||
local has_tunneldigger = fs.access('/lib/gluon/mesh-vpn/tunneldigger')
|
||||
local has_fastd = unistd.access('/lib/gluon/mesh-vpn/fastd')
|
||||
local has_tunneldigger = unistd.access('/lib/gluon/mesh-vpn/tunneldigger')
|
||||
|
||||
return function(form, uci)
|
||||
if not (has_fastd or has_tunneldigger) then
|
||||
|
@ -9,12 +9,12 @@ You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
-%>
|
||||
<%
|
||||
local uci = require("simple-uci").cursor()
|
||||
local fs = require "nixio.fs"
|
||||
local pretty_hostname = require "pretty_hostname"
|
||||
local uci = require("simple-uci").cursor()
|
||||
local util = require "gluon.util"
|
||||
|
||||
local hostname = pretty_hostname.get(uci)
|
||||
local release = fs.readfile("/lib/gluon/release")
|
||||
local release = util.readfile("/lib/gluon/release")
|
||||
|
||||
local root = node()
|
||||
local rnode = node(unpack(request))
|
||||
|
Loading…
Reference in New Issue
Block a user