-
-
Save maurerle/fc5a9b4c7b63fc4feab845bc43f7150b to your computer and use it in GitHub Desktop.
FFULM Migration Script - rev2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/lua | |
-- Install at /lib/setup-mode/rc.d/S14-migrate (chmod +x) | |
local site = require 'gluon.site' | |
local uci = require('simple-uci').cursor() | |
local util = require 'gluon.util' | |
local pretty_hostname = require 'pretty_hostname' | |
local freifunk_settings = uci:get_first('freifunk', 'settings') | |
if freifunk_settings ~= nil then | |
-- Try to migrate the hostname | |
local hostname = uci:get('freifunk', freifunk_settings, 'name') | |
local default_hostname = util.default_hostname() | |
pretty_hostname.set(uci, hostname or default_hostname) | |
uci:save('system') | |
-- Try to migrate the contact | |
local contact = uci:get('freifunk', freifunk_settings, 'contact') | |
local owner = uci:get_first("gluon-node-info", "owner") | |
local default_contact = uci:get("gluon-node-info", owner, "contact") | |
uci:set("gluon-node-info", owner, "contact", contact or default_contact) | |
uci:save("gluon-node-info") | |
-- Try to migrate the location | |
local latitude = uci:get('freifunk', freifunk_settings, 'latitude') | |
local longitude = uci:get('freifunk', freifunk_settings, 'longitude') | |
local location = uci:get_first("gluon-node-info", "location") | |
uci:set("gluon-node-info", location, "latitude", latitude) | |
uci:set("gluon-node-info", location, "longitude", longitude) | |
uci:save("gluon-node-info") | |
-- Try to migrate mesh-on-wan | |
local mesh_on_wan = uci:get_bool('freifunk', freifunk_settings, 'mesh_on_wan') | |
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') | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/etc/uhttpd should be removed too