Browse Source

With 2018.2 nixio has been replaced with luaposix

Michael Schwarz 4 months ago
parent
commit
1f4b29c4e6

+ 4 - 2
ffho-autoupdater-wifi-fallback/luasrc/lib/gluon/upgrade/510-autoupdater-wifi-fallback

@@ -1,7 +1,6 @@
 #!/usr/bin/lua
 
 local uci = require('simple-uci').cursor()
-local fs = require 'nixio.fs'
 
 local enabled
 if uci:get('autoupdater-wifi-fallback', 'settings') then
@@ -35,7 +34,10 @@ uci:save('autoupdater-wifi-fallback')
 uci:save('network')
 uci:save('wireless')
 
-local minute = tonumber(fs.readfile('/usr/lib/micron.d/autoupdater'):match('^([0-9][0-9]?)%s'))
+local file = io.open('/usr/lib/micron.d/autoupdater', 'r')
+local content = file:read "*a"
+local minute = tonumber(content:match('^([0-9][0-9]?)%s'))
+file:close()
 minute = (minute + 10) % 60
 
 local f = io.open('/usr/lib/micron.d/autoupdater-wifi-fallback', 'w')

+ 4 - 2
ffho-autoupdater-wifi-fallback/luasrc/usr/sbin/autoupdater-wifi-fallback

@@ -1,5 +1,4 @@
 #!/usr/bin/lua
-local fs = require 'nixio.fs'
 local uci = require('simple-uci').cursor()
 local autil = require 'autoupdater-wifi-fallback.util'
 local util = require 'gluon.util'
@@ -38,7 +37,10 @@ local function preflight_check()
   if not uci:get_bool('autoupdater', 'settings', 'enabled') then
     return false
   end
-  if tonumber(fs.readfile('/proc/uptime'):match('^([^ ]+) ')) < min_uptime_secs then
+  local f = io.open('/proc/uptime')
+  local c = f.read "*a"
+  f:close()
+  if tonumber(c:match('^([^ ]+) ')) < min_uptime_secs then
     return false
   end
 

+ 3 - 3
ffho-domain-migration/luasrc/lib/gluon/upgrade/002-domain-migration

@@ -1,6 +1,6 @@
 #!/usr/bin/lua
 
-local fs = require 'nixio.fs'
+local sys_stat = require 'posix.sys.stat'
 local uci = require("simple-uci").cursor()
 
 local file = '/etc/config/currentsite'
@@ -11,7 +11,7 @@ end
 if uci:get('gluon', 'system') then
 	uci:delete('gluon', 'system')
 end
-if fs.stat(file) then
+if sys_stat.stat(file) then
 	local domain = uci:get('currentsite', 'current', 'name')
 
 	-- We can't use gluon.site yet, as it depends on gluon.core.domain to be set
@@ -22,7 +22,7 @@ if fs.stat(file) then
 		domain = domain:match(site.domain_migration.match) or domain
 	end
 	uci:set('gluon', 'core', 'domain', domain)
-	fs.remove(file)
+	os.remove(file)
 end
 
 uci:save('gluon')