diff --git a/package/gluon-mesh-olsrd/luasrc/lib/gluon/upgrade/500-dhcp-hack b/package/gluon-mesh-olsrd/luasrc/lib/gluon/upgrade/500-dhcp-hack deleted file mode 100755 index 4577d3e7..00000000 --- a/package/gluon-mesh-olsrd/luasrc/lib/gluon/upgrade/500-dhcp-hack +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/lua - -local uci = require('simple-uci').cursor() - --- this hack directly uses the mesh interface as I haven't figured out teql and ddhcpd now and this shit should just work already - -if uci:get('wireless', 'client_radio0', 'network') then - uci:set('wireless', 'client_radio0', 'network', 'mesh_radio0') - uci:save('wireless') -end diff --git a/package/gluon-static-ip/luasrc/lib/gluon/upgrade/440-static-ip b/package/gluon-static-ip/luasrc/lib/gluon/upgrade/440-static-ip deleted file mode 100755 index f3ef4dda..00000000 --- a/package/gluon-static-ip/luasrc/lib/gluon/upgrade/440-static-ip +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/lua - -local uci = require('simple-uci').cursor() -local site = require 'gluon.site' -local wireless = require 'gluon.wireless' -local ip = require 'luci.ip' -- luci-lib-ip -local util = require 'gluon.util' - -IPV4_PREFIX_MAX = 32 - -local tmp4 = ip.new(site.tmpIpPrefix4()) - -function startswith(text, prefix) - return text:find(prefix, 1, true) == 1 -end - -local function static_ip_4(name, ifname, macaddr, actually_use) - -- actually_use = if ip should be applied to interface or not - -- if set and actually_use=false then it will be removed - local static4 = uci:get('gluon-static-ip', name, 'ip4') - - if not static4 then - local prefixOverflow = IPV4_PREFIX_MAX - tmp4:prefix() - -- magic that turns mac into random number - local ipnum = math.fmod(tonumber(macaddr:gsub(':', ''):sub(-6), 16), 2 ^ prefixOverflow) - - -- the rare case where we get 0 or 1 as our mac based number - if ipnum < 2 then - ipnum = 2 - end - - static4 = tmp4:add(ipnum):string() - uci:section('gluon-static-ip', 'interface', name, { - ip4 = static4, - }) - end - - if actually_use then - ip4 = ip.new(static4) - -- we have to set proto to static as otherwise we won't have the ip assigned - -- TODO: maybe modify the protos instead to allow reading static ips and using them? - -- NOTE: wan also uses dhcp/static directly - uci:set('network', name, 'proto', 'static') - uci:set('network', name, 'ipaddr', ip4:host():string()) - uci:set('network', name, 'netmask', ip4:mask():string()) - else - if uci:get('network', name, 'proto') == 'static' then - uci:del('network', name, 'ipaddr') - uci:del('network', name, 'netmask') - end - end -end - -wireless.foreach_radio(uci, function(radio, index, config) - net = 'mesh_' .. radio['.name'] - - if uci:get('network', net, 'proto') == nil then - uci:section('network', 'interface', net, { - proto = 'static', - type = 'bridge', - ifname = net, - }) - end - - use = uci:get('wifi-iface', net, 'disabled') ~= '1' - static_ip_4(net, uci:get('wifi-iface', net, 'ifname'), uci:get('wifi-iface', net, 'macaddr'), use) -end) - -local function apply_network(name, use, mac) - if not uci:get('network', name, 'proto') then - print('warn: non-existent network ' .. name) - return - end - - not_disabled = uci:get('network', name, 'disabled') ~= '1' - if use == nil then - use = not_disabled - end - macaddr = uci:get('network', name, 'macaddr') - if not macaddr then - macaddr = util.generate_mac(mac) - uci:set('network', name, 'macaddr', macaddr) - end - static_ip_4(name, uci:get('network', name, 'ifname'), macaddr, use) -end - -if pcall(function() require 'gluon.mesh-vpn' end) then - local vpn_core = require 'gluon.mesh-vpn' - - apply_network('mesh_vpn', vpn_core.enabled(), 7) -end - -local wan_mesh = not uci:get_bool('network', 'mesh_wan', 'disabled') -apply_network('mesh_wan', wan_mesh, 10) - -if uci:get('network', 'mesh_lan', 'proto') then - local lan_mesh = not uci:get_bool('network', 'mesh_lan', 'disabled') - apply_network('mesh_lan', lan_mesh, 11) -end - -uci:save('gluon-static-ip') -uci:save('network')