diff --git a/patches/migration-ulm.patch b/patches/migration-ulm.patch index 92c22299..4192a186 100644 --- a/patches/migration-ulm.patch +++ b/patches/migration-ulm.patch @@ -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) @@ -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._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