gluon-core: convert all initial scripts to invariant scripts
This commit is contained in:
parent
71c498edd2
commit
6f11279438
@ -1,38 +0,0 @@
|
|||||||
#!/usr/bin/lua
|
|
||||||
|
|
||||||
local sysconfig = require 'gluon.sysconfig'
|
|
||||||
local gluon_util = require 'gluon.util'
|
|
||||||
local platform = require 'gluon.platform'
|
|
||||||
|
|
||||||
local fs = require 'luci.fs'
|
|
||||||
local uci = require('luci.model.uci').cursor()
|
|
||||||
local util = require 'luci.util'
|
|
||||||
|
|
||||||
|
|
||||||
if platform.match('ar71xx', 'generic', {'tl-wdr3600', 'tl-wdr4300'}) then
|
|
||||||
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress'))
|
|
||||||
else
|
|
||||||
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy0/macaddress'))
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function iface_exists(name)
|
|
||||||
return (gluon_util.exec('ip', 'link', 'show', 'dev', (name:gsub('%..*$', ''))) == 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local lan_ifname = uci:get('network', 'lan', 'ifname')
|
|
||||||
local wan_ifname = uci:get('network', 'wan', 'ifname')
|
|
||||||
|
|
||||||
|
|
||||||
if platform.match('ar71xx', 'generic', {'cpe510', 'nanostation-m', 'nanostation-m-xw'}) then
|
|
||||||
lan_ifname, wan_ifname = wan_ifname, lan_ifname
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
if wan_ifname and iface_exists(wan_ifname) then
|
|
||||||
sysconfig.wan_ifname = wan_ifname
|
|
||||||
sysconfig.lan_ifname = lan_ifname
|
|
||||||
else
|
|
||||||
sysconfig.wan_ifname = lan_ifname
|
|
||||||
end
|
|
@ -1,14 +0,0 @@
|
|||||||
#!/usr/bin/lua
|
|
||||||
|
|
||||||
local site = require 'gluon.site_config'
|
|
||||||
local util = require 'gluon.util'
|
|
||||||
local uci = require 'luci.model.uci'
|
|
||||||
|
|
||||||
local c = uci.cursor()
|
|
||||||
local system = c:get_first('system', 'system')
|
|
||||||
|
|
||||||
c:set('system', system, 'hostname', site.hostname_prefix .. '-' .. util.node_id())
|
|
||||||
c:set('system', system, 'timezone', site.timezone)
|
|
||||||
|
|
||||||
c:save('system')
|
|
||||||
c:commit('system')
|
|
@ -1,9 +0,0 @@
|
|||||||
#!/usr/bin/lua
|
|
||||||
|
|
||||||
local uci = require('luci.model.uci').cursor()
|
|
||||||
|
|
||||||
uci:delete('network', 'lan')
|
|
||||||
uci:delete('network', 'wan')
|
|
||||||
|
|
||||||
uci:save('network')
|
|
||||||
uci:commit('network')
|
|
@ -1,7 +0,0 @@
|
|||||||
#!/usr/bin/lua
|
|
||||||
|
|
||||||
local uci = require('luci.model.uci').cursor()
|
|
||||||
|
|
||||||
uci:delete_all('wireless', 'wifi-iface')
|
|
||||||
uci:save('wireless')
|
|
||||||
uci:commit('wireless')
|
|
10
package/gluon-core/files/lib/gluon/upgrade/core/invariant/001-upgrade
Executable file
10
package/gluon-core/files/lib/gluon/upgrade/core/invariant/001-upgrade
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local fs = require 'luci.fs'
|
||||||
|
local sysconfig = require 'gluon.sysconfig'
|
||||||
|
|
||||||
|
|
||||||
|
if fs.isfile('/lib/gluon/version/core') and not sysconfig.gluon_version then
|
||||||
|
-- This isn't an initial upgrade, so set gluon_version
|
||||||
|
sysconfig.gluon_version = ''
|
||||||
|
end
|
16
package/gluon-core/files/lib/gluon/upgrade/core/invariant/010-primary-mac
Executable file
16
package/gluon-core/files/lib/gluon/upgrade/core/invariant/010-primary-mac
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local sysconfig = require 'gluon.sysconfig'
|
||||||
|
local platform = require 'gluon.platform'
|
||||||
|
|
||||||
|
local fs = require 'luci.fs'
|
||||||
|
local util = require 'luci.util'
|
||||||
|
|
||||||
|
|
||||||
|
if not sysconfig.primary_mac then
|
||||||
|
if platform.match('ar71xx', 'generic', {'tl-wdr3600', 'tl-wdr4300'}) then
|
||||||
|
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress'))
|
||||||
|
else
|
||||||
|
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy0/macaddress'))
|
||||||
|
end
|
||||||
|
end
|
36
package/gluon-core/files/lib/gluon/upgrade/core/invariant/020-interfaces
Executable file
36
package/gluon-core/files/lib/gluon/upgrade/core/invariant/020-interfaces
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local sysconfig = require 'gluon.sysconfig'
|
||||||
|
local gluon_util = require 'gluon.util'
|
||||||
|
local platform = require 'gluon.platform'
|
||||||
|
|
||||||
|
local uci = require('luci.model.uci').cursor()
|
||||||
|
|
||||||
|
|
||||||
|
if not (sysconfig.lan_ifname or sysconfig.wan_ifname) then
|
||||||
|
local function iface_exists(name)
|
||||||
|
return (gluon_util.exec('ip', 'link', 'show', 'dev', (name:gsub('%..*$', ''))) == 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local lan_ifname = uci:get('network', 'lan', 'ifname')
|
||||||
|
local wan_ifname = uci:get('network', 'wan', 'ifname')
|
||||||
|
|
||||||
|
if platform.match('ar71xx', 'generic', {'cpe510', 'nanostation-m', 'nanostation-m-xw'}) then
|
||||||
|
lan_ifname, wan_ifname = wan_ifname, lan_ifname
|
||||||
|
end
|
||||||
|
|
||||||
|
if wan_ifname and iface_exists(wan_ifname) then
|
||||||
|
sysconfig.wan_ifname = wan_ifname
|
||||||
|
sysconfig.lan_ifname = lan_ifname
|
||||||
|
else
|
||||||
|
sysconfig.wan_ifname = lan_ifname
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
uci:delete('network', 'lan')
|
||||||
|
uci:delete('network', 'wan')
|
||||||
|
|
||||||
|
uci:save('network')
|
||||||
|
uci:commit('network')
|
||||||
|
end
|
18
package/gluon-core/files/lib/gluon/upgrade/core/invariant/030-system
Executable file
18
package/gluon-core/files/lib/gluon/upgrade/core/invariant/030-system
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local sysconfig = require 'gluon.sysconfig'
|
||||||
|
|
||||||
|
-- Initial
|
||||||
|
if not sysconfig.gluon_version then
|
||||||
|
local site = require 'gluon.site_config'
|
||||||
|
local util = require 'gluon.util'
|
||||||
|
local uci = require('luci.model.uci').cursor()
|
||||||
|
|
||||||
|
local system = uci:get_first('system', 'system')
|
||||||
|
|
||||||
|
uci:set('system', system, 'hostname', site.hostname_prefix .. '-' .. util.node_id())
|
||||||
|
uci:set('system', system, 'timezone', site.timezone)
|
||||||
|
|
||||||
|
uci:save('system')
|
||||||
|
uci:commit('system')
|
||||||
|
end
|
12
package/gluon-core/files/lib/gluon/upgrade/core/invariant/200-wireless
Executable file
12
package/gluon-core/files/lib/gluon/upgrade/core/invariant/200-wireless
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local sysconfig = require 'gluon.sysconfig'
|
||||||
|
|
||||||
|
-- Initial
|
||||||
|
if not sysconfig.gluon_version then
|
||||||
|
local uci = require('luci.model.uci').cursor()
|
||||||
|
|
||||||
|
uci:delete_all('wireless', 'wifi-iface')
|
||||||
|
uci:save('wireless')
|
||||||
|
uci:commit('wireless')
|
||||||
|
end
|
11
package/gluon-core/files/lib/gluon/upgrade/core/invariant/999-version
Executable file
11
package/gluon-core/files/lib/gluon/upgrade/core/invariant/999-version
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local sysconfig = require 'gluon.sysconfig'
|
||||||
|
|
||||||
|
local fs = require 'luci.fs'
|
||||||
|
local util = require 'luci.util'
|
||||||
|
|
||||||
|
|
||||||
|
-- Save the Gluon version in the sysconfig so we know which version we
|
||||||
|
-- upgraded from after the next upgrade
|
||||||
|
sysconfig.gluon_version = util.trim(fs.readfile('/lib/gluon/gluon-version'))
|
Loading…
Reference in New Issue
Block a user