gluon-config-mode-*: replace nixio with gluon.util
This commit is contained in:
		
							parent
							
								
									90031ba97a
								
							
						
					
					
						commit
						92d90cdfb7
					
				| @ -1,20 +1,13 @@ | |||||||
| <h2><%:Your node's setup is now complete.%></h2> | <h2><%:Your node's setup is now complete.%></h2> | ||||||
| <% | <% | ||||||
| 	local fs = require "nixio.fs" | 	local util = require "gluon.util" | ||||||
| 	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 parts = {} | 	local parts = {} | ||||||
| 	for _, entry in ipairs(files) do | 	for _, entry in ipairs(util.glob('/lib/gluon/config-mode/reboot/*')) do | ||||||
| 		if entry:sub(1, 1) ~= '.' then | 		local p = assert(loadfile(entry)) | ||||||
| 			local p = assert(loadfile(parts_dir .. entry)) |  | ||||||
| 		setfenv(p, getfenv()) | 		setfenv(p, getfenv()) | ||||||
| 		table.insert(parts, p) | 		table.insert(parts, p) | ||||||
| 	end | 	end | ||||||
| 	end |  | ||||||
| 
 | 
 | ||||||
| 	for _, p in ipairs(parts) do | 	for _, p in ipairs(parts) do | ||||||
| 		p() | 		p() | ||||||
|  | |||||||
| @ -1,23 +1,14 @@ | |||||||
| local fs = require "nixio.fs" |  | ||||||
| local util = require "gluon.util" | local util = require "gluon.util" | ||||||
| local nixio_util = require "nixio.util" |  | ||||||
| 
 |  | ||||||
| local uci = require("simple-uci").cursor() | 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 = {} | local wizard = {} | ||||||
| for _, entry in ipairs(files) do | for _, entry in ipairs(util.glob('/lib/gluon/config-mode/wizard/*')) do | ||||||
| 	if entry:sub(1, 1) ~= '.' then | 	local f = assert(loadfile(entry)) | ||||||
| 		local f = assert(loadfile(wizard_dir .. entry)) |  | ||||||
| 	setfenv(f, getfenv()) | 	setfenv(f, getfenv()) | ||||||
| 	local w = f() | 	local w = f() | ||||||
| 	table.insert(wizard, w) | 	table.insert(wizard, w) | ||||||
| end | end | ||||||
| end |  | ||||||
| 
 | 
 | ||||||
| local f = Form(translate("Welcome!")) | local f = Form(translate("Welcome!")) | ||||||
| f.submit = translate('Save & restart') | f.submit = translate('Save & restart') | ||||||
| @ -45,7 +36,8 @@ for _, w in ipairs(wizard) do | |||||||
| end | end | ||||||
| 
 | 
 | ||||||
| function f:write() | 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) | 	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.package = "gluon-config-mode-core" | ||||||
| 	f.hidenav = true | 	f.hidenav = true | ||||||
| 
 | 
 | ||||||
| 	if nixio.fork() == 0 then | 	if unistd.fork() == 0 then | ||||||
| 		-- Replace stdout with /dev/null | 		-- 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 | 		-- 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(1) | 		unistd.sleep(1) | ||||||
| 
 | 
 | ||||||
| 		nixio.execp("reboot") | 		unistd.execp('reboot', {[0] = 'reboot'}) | ||||||
| 	end | 	end | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,7 +2,6 @@ | |||||||
| return function(form, uci) | return function(form, uci) | ||||||
| 	local site_i18n = i18n 'gluon-site' | 	local site_i18n = i18n 'gluon-site' | ||||||
| 
 | 
 | ||||||
| 	local fs = require 'nixio.fs' |  | ||||||
| 	local json = require 'jsonc' | 	local json = require 'jsonc' | ||||||
| 	local site = require 'gluon.site' | 	local site = require 'gluon.site' | ||||||
| 	local util = require 'gluon.util' | 	local util = require 'gluon.util' | ||||||
| @ -22,7 +21,7 @@ return function(form, uci) | |||||||
| 
 | 
 | ||||||
| 	local function get_domain_list() | 	local function get_domain_list() | ||||||
| 		local 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_code = domain_path:match('([^/]+)%.json$') | ||||||
| 			local domain = assert(json.load(domain_path)) | 			local domain = assert(json.load(domain_path)) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| local site_i18n = i18n 'gluon-site' | local site_i18n = i18n 'gluon-site' | ||||||
| 
 | 
 | ||||||
| local uci = require("simple-uci").cursor() | local uci = require("simple-uci").cursor() | ||||||
| local fs = require "nixio.fs" | local unistd = require 'posix.unistd' | ||||||
| 
 | 
 | ||||||
| local platform = require 'gluon.platform' | local platform = require 'gluon.platform' | ||||||
| local site = require 'gluon.site' | local site = require 'gluon.site' | ||||||
| @ -11,8 +11,8 @@ local util = require "gluon.util" | |||||||
| local pretty_hostname = require 'pretty_hostname' | local pretty_hostname = require 'pretty_hostname' | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| local has_fastd = fs.access('/lib/gluon/mesh-vpn/fastd') | local has_fastd = unistd.access('/lib/gluon/mesh-vpn/fastd') | ||||||
| local has_tunneldigger = fs.access('/lib/gluon/mesh-vpn/tunneldigger') | local has_tunneldigger = unistd.access('/lib/gluon/mesh-vpn/tunneldigger') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| local hostname = pretty_hostname.get(uci) | 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_fastd = unistd.access('/lib/gluon/mesh-vpn/fastd') | ||||||
| local has_tunneldigger = fs.access('/lib/gluon/mesh-vpn/tunneldigger') | local has_tunneldigger = unistd.access('/lib/gluon/mesh-vpn/tunneldigger') | ||||||
| 
 | 
 | ||||||
| return function(form, uci) | return function(form, uci) | ||||||
| 	if not (has_fastd or has_tunneldigger) then | 	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 | 	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 pretty_hostname = require "pretty_hostname" | ||||||
|  | 	local uci  = require("simple-uci").cursor() | ||||||
|  | 	local util = require "gluon.util" | ||||||
| 
 | 
 | ||||||
| 	local hostname = pretty_hostname.get(uci) | 	local hostname = pretty_hostname.get(uci) | ||||||
| 	local release = fs.readfile("/lib/gluon/release") | 	local release = util.readfile("/lib/gluon/release") | ||||||
| 
 | 
 | ||||||
| 	local root = node() | 	local root = node() | ||||||
| 	local rnode = node(unpack(request)) | 	local rnode = node(unpack(request)) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user