Skip to content

Commit

Permalink
do not try to migrate network config, as it has already been deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
maurerle authored and grische committed Apr 7, 2024
1 parent fd6aaa8 commit fde18d2
Showing 1 changed file with 16 additions and 82 deletions.
98 changes: 16 additions & 82 deletions patches/migration-ulm.patch
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
diff --git a/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S14-migrate b/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S14-migrate
new file mode 100755
index 00000000..dcf0483c
index 00000000..1e7cc0b9
--- /dev/null
+++ b/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S14-migrate
@@ -0,0 +1,129 @@
@@ -0,0 +1,63 @@
+#!/usr/bin/lua
+
+-- Install at /lib/setup-mode/rc.d/S14-migrate (chmod +x)
Expand Down Expand Up @@ -42,94 +42,28 @@ index 00000000..dcf0483c
+
+ -- Try to migrate mesh-on-wan
+ local mesh_on_wan = uci:get_bool('freifunk', freifunk_settings, 'mesh_on_wan')
+ -- TODO write
+
+ if not mesh_on_wan then
+ -- TODO also check mesh_on_lan, if both disabled mesh_vpn must be true
+ -- TODO check if enabled in orig config
+ uci:set("gluon", "mesh_vpn", "enabled", true)
+ end
+
+ uci:set("network", "mesh_wan", "disabled", not mesh_on_wan)
+ uci:set("gluon", "mesh_vpn", "enabled", not mesh_on_wan)
+ -- As the network section is lost - we have to keep the lan interface configured as default
+
+ -- Set domain
+ uci:set('gluon', 'core', 'domain', "ffmuc_welt") -- TODO change to ulm
+ uci:save('gluon')
+
+
+ if uci:get('network', 'wan') ~= nil then
+ -- Try to migrate interface config
+ local wan_ifnames = uci:get('network', 'wan', 'ifname') -- translates to uplink
+ local lan_ifnames = uci:get('network', 'lan', 'ifname') -- sets up a local private network without internet access for node configuration (?)
+ -- -> no equivalent in gluon, migrate to client
+ local mesh_ifnames = uci:get('network', 'mesh', 'ifname') -- translates to mesh
+ local freifunk_ifnames = uci:get('network', 'freifunk', 'ifname') -- translates to client
+
+ local function has_value (tab, val)
+ for index, value in ipairs(tab) do
+ if value == val then
+ return true
+ end
+ end
+
+ return false
+ end
+
+
+ function getInterfaceMode(ifname)
+ if has_value(freifunk_ifnames, ifname) then
+ return 'client'
+ end
+ if has_value(lan_ifnames, ifname) then
+ return 'client'
+ end
+ if has_value(wan_ifnames, ifname) then
+ return 'uplink'
+ end
+
+ -- TODO
+ --[[
+ Figure out how mesh interfaces are added (maybe as network.<ifname>_mesh?)
+ Search through the list or something and check for .proto == batadv_hardif
+
+ # uci show network.fastd_mesh
+ network.fastd_mesh=interface
+ network.fastd_mesh.ifname='fastd_mesh'
+ network.fastd_mesh.mtu='1406'
+ network.fastd_mesh.proto='batadv_hardif'
+ network.fastd_mesh.master='bat0
+
+ if has_value(mesh_ifnames, ifname) then
+ return 'mesh'
+ end
+ if config_find(n, {ifname = ifname, proto = 'batadv_hardif'}) then
+ return 'mesh'
+ end
+ --]]
+
+ return 'none' -- TODO
+ end
+
+
+ uci:foreach('gluon', 'interface', function(config)
+ local section_name = config['.name']
+ uci:set_list("gluon", section_name, "role", getInterfaceMode(section_name))
+ end)
+ uci:save("gluon")
+ end
+
+
+
+ -- pcall(os.remove('/etc/config/freifunk'))
+ -- pcall(os.remove('/etc/config/fastd'))
+ -- pcall(os.remove('/etc/config/network'))
+ -- pcall(os.remove('/etc/config/alfred'))
+ -- pcall(os.remove('/etc/config/firewall'))
+ -- pcall(os.remove('/etc/config/dhcp'))
+ -- pcall(os.remove('/etc/config/simple-radvd'))
+ -- pcall(os.remove('/etc/config/wireless'))
+ os.remove('/etc/config/freifunk')
+ os.remove('/etc/config/fastd')
+ -- already overwritten
+ -- os.remove('/etc/config/network')
+ -- os.remove('/etc/config/wireless')
+ os.remove('/etc/config/alfred')
+ os.remove('/etc/config/firewall')
+ os.remove('/etc/config/dhcp')
+ os.remove('/etc/config/simple-radvd')
+
+
+ local name = uci:get_first("gluon-setup-mode", "setup_mode")
+ uci:set("gluon-setup-mode", name, "configured", true)
+ uci:save('gluon-setup-mode')
+ -- os.execute('exec gluon-reconfigure >/dev/null')
+ -- os.execute("/etc/init.d/done boot; reboot")
+end

0 comments on commit fde18d2

Please sign in to comment.