diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/initial/001-sysconfig b/package/gluon-core/files/lib/gluon/upgrade/core/initial/001-sysconfig deleted file mode 100755 index 8181be6c..00000000 --- a/package/gluon-core/files/lib/gluon/upgrade/core/initial/001-sysconfig +++ /dev/null @@ -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 diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/initial/010-gluon-system b/package/gluon-core/files/lib/gluon/upgrade/core/initial/010-gluon-system deleted file mode 100755 index bf5d7816..00000000 --- a/package/gluon-core/files/lib/gluon/upgrade/core/initial/010-gluon-system +++ /dev/null @@ -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') diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/initial/011-gluon-network b/package/gluon-core/files/lib/gluon/upgrade/core/initial/011-gluon-network deleted file mode 100755 index 64fd2830..00000000 --- a/package/gluon-core/files/lib/gluon/upgrade/core/initial/011-gluon-network +++ /dev/null @@ -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') diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/initial/020-wireless b/package/gluon-core/files/lib/gluon/upgrade/core/initial/020-wireless deleted file mode 100755 index bf4af393..00000000 --- a/package/gluon-core/files/lib/gluon/upgrade/core/initial/020-wireless +++ /dev/null @@ -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') diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/invariant/001-upgrade b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/001-upgrade new file mode 100755 index 00000000..6caba148 --- /dev/null +++ b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/001-upgrade @@ -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 diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/invariant/010-primary-mac b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/010-primary-mac new file mode 100755 index 00000000..aa5e8732 --- /dev/null +++ b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/010-primary-mac @@ -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 diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/invariant/020-interfaces b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/020-interfaces new file mode 100755 index 00000000..077f77be --- /dev/null +++ b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/020-interfaces @@ -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 diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/invariant/030-system b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/030-system new file mode 100755 index 00000000..b31ba42e --- /dev/null +++ b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/030-system @@ -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 diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/invariant/010-dnsmasq b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/100-dnsmasq similarity index 100% rename from package/gluon-core/files/lib/gluon/upgrade/core/invariant/010-dnsmasq rename to package/gluon-core/files/lib/gluon/upgrade/core/invariant/100-dnsmasq diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/invariant/011-network b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/110-network similarity index 100% rename from package/gluon-core/files/lib/gluon/upgrade/core/invariant/011-network rename to package/gluon-core/files/lib/gluon/upgrade/core/invariant/110-network diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/invariant/012-ntp-servers b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/120-ntp-servers similarity index 100% rename from package/gluon-core/files/lib/gluon/upgrade/core/invariant/012-ntp-servers rename to package/gluon-core/files/lib/gluon/upgrade/core/invariant/120-ntp-servers diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/invariant/013-reboot-on-oom b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/130-reboot-on-oom similarity index 100% rename from package/gluon-core/files/lib/gluon/upgrade/core/invariant/013-reboot-on-oom rename to package/gluon-core/files/lib/gluon/upgrade/core/invariant/130-reboot-on-oom diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/invariant/014-firewall-rules b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/140-firewall-rules similarity index 100% rename from package/gluon-core/files/lib/gluon/upgrade/core/invariant/014-firewall-rules rename to package/gluon-core/files/lib/gluon/upgrade/core/invariant/140-firewall-rules diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/invariant/200-wireless b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/200-wireless new file mode 100755 index 00000000..219e505d --- /dev/null +++ b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/200-wireless @@ -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 diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/invariant/999-version b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/999-version new file mode 100755 index 00000000..62f08206 --- /dev/null +++ b/package/gluon-core/files/lib/gluon/upgrade/core/invariant/999-version @@ -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'))