From e73f79f392fd21cbb9bec9d54518d7cf821f6274 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer <mschiffer@universe-factory.net> Date: Thu, 3 Oct 2013 18:04:03 +0200 Subject: [PATCH] Move some more configuration into the corrent packages, correctly configure multiple radios --- .../gluon/upgrade/core/initial/020-wireless | 28 +++----- package/gluon-mesh-batman-adv/Makefile | 1 + .../initial/{011-mesh => 010-mesh} | 12 ---- .../mesh-batman-adv/initial/020-wireless | 64 +++++++++++++++++++ package/gluon-mesh-vpn-fastd/fastd.pl | 6 ++ 5 files changed, 79 insertions(+), 32 deletions(-) rename package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/initial/{011-mesh => 010-mesh} (72%) create mode 100755 package/gluon-mesh-batman-adv/generate/lib/gluon/upgrade/mesh-batman-adv/initial/020-wireless diff --git a/package/gluon-core/generate/lib/gluon/upgrade/core/initial/020-wireless b/package/gluon-core/generate/lib/gluon/upgrade/core/initial/020-wireless index 944d84a40..0196b9519 100755 --- a/package/gluon-core/generate/lib/gluon/upgrade/core/initial/020-wireless +++ b/package/gluon-core/generate/lib/gluon/upgrade/core/initial/020-wireless @@ -1,26 +1,14 @@ #!/bin/sh -uci -q batch <<EOF -delete wireless.radio0.disabled -delete wireless.@wifi-iface[0] +. /lib/functions.sh -set wireless.radio0.channel='@wifi24.channel@' -set wireless.radio0.htmode='@wifi24.htmode@' -set wireless.radio0.country='DE' +config_load wireless -set wireless.wifi_client='wifi-iface' -set wireless.wifi_client.device='radio0' -set wireless.wifi_client.network='client' -set wireless.wifi_client.mode='ap' -set wireless.wifi_client.ssid='@wifi24.ssid@' +delete_iface() { + local iface="$1" -set wireless.wifi_mesh='wifi-iface' -set wireless.wifi_mesh.device='radio0' -set wireless.wifi_mesh.network='mesh' -set wireless.wifi_mesh.mode='adhoc' -set wireless.wifi_mesh.ssid='@wifi24.mesh_ssid@' -set wireless.wifi_mesh.bssid='@wifi24.mesh_bssid@' -set wireless.wifi_mesh.mcast_rate='12000' + uci_remove wireless "$iface" +} -commit wireless -EOF +config_foreach delete_iface 'wifi-iface' +uci_commit wireless diff --git a/package/gluon-mesh-batman-adv/Makefile b/package/gluon-mesh-batman-adv/Makefile index 7bb38bb11..708c7c4a9 100644 --- a/package/gluon-mesh-batman-adv/Makefile +++ b/package/gluon-mesh-batman-adv/Makefile @@ -31,6 +31,7 @@ endef define Package/gluon-mesh-batman-adv/install $(CP) ./files/* $(1)/ + $(GLUON_GENERATE) ./generate/* $(1)/ endef $(eval $(call BuildPackage,gluon-mesh-batman-adv)) diff --git a/package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/initial/011-mesh b/package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/initial/010-mesh similarity index 72% rename from package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/initial/011-mesh rename to package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/initial/010-mesh index 1fc2b91ff..b18c975de 100755 --- a/package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/initial/011-mesh +++ b/package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/initial/010-mesh @@ -11,25 +11,13 @@ set batman-adv.bat0='mesh' set batman-adv.bat0.orig_interval='5000' commit batman-adv -EOF -uci -q batch <<EOF set network.client='interface' set network.client.ifname='$(sysconfig lan_ifname) bat0' set network.client.type='bridge' set network.client.proto='dhcpv6' set network.client.reqprefix='no' set network.client.peerdns='0' - -set network.mesh='interface' -set network.mesh.proto='batadv' -set network.mesh.mtu='1528' -set network.mesh.mesh='bat0' - -set network.mesh_vpn='interface' -set network.mesh_vpn.ifname='mesh-vpn' -set network.mesh_vpn.proto='batadv' -set network.mesh_vpn.mesh='bat0' EOF diff --git a/package/gluon-mesh-batman-adv/generate/lib/gluon/upgrade/mesh-batman-adv/initial/020-wireless b/package/gluon-mesh-batman-adv/generate/lib/gluon/upgrade/mesh-batman-adv/initial/020-wireless new file mode 100755 index 000000000..dbca73d7d --- /dev/null +++ b/package/gluon-mesh-batman-adv/generate/lib/gluon/upgrade/mesh-batman-adv/initial/020-wireless @@ -0,0 +1,64 @@ +#!/bin/sh + +. /lib/functions.sh + +config_load wireless + +configure_radio() { + local radio="$1" + local channel; local htmode; local ssid; local mesh_ssid; local mesh_bssid; local mesh_mcast_rate + + config_get hwmode "$radio" 'hwmode' + + case "$hwmode" in + 11g|11ng) + channel='@wifi24.channel@' + htmode='@wifi24.htmode@' + + ssid='@wifi24.ssid@' + mesh_ssid='@wifi24.mesh_ssid@' + mesh_bssid='@wifi24.mesh_bssid@' + mesh_mcast_rate='@wifi24.mesh_mcast_rate@' + ;; + 11a|11na) + channel='@wifi5.channel@' + htmode='@wifi5.htmode@' + + ssid='@wifi5.ssid@' + mesh_ssid='@wifi5.mesh_ssid@' + mesh_bssid='@wifi5.mesh_bssid@' + mesh_mcast_rate='@wifi5.mesh_mcast_rate@' + ;; + *) + return + esac + + uci_remove wireless "$radio" 'disabled' + + uci_set wireless "$radio" channel "$channel" + uci_set wireless "$radio" htmode "$htmode" + uci_set wireless "$radio" country '@regdom@' + + uci_add wireless 'wifi-iface' "client_${radio}" + uci_set wireless "client_${radio}" device "$radio" + uci_set wireless "client_${radio}" network 'client' + uci_set wireless "client_${radio}" mode 'ap' + uci_set wireless "client_${radio}" ssid "$ssid" + + uci_add network 'interface' "mesh_${radio}" + uci_set network "mesh_${radio}" proto 'batadv' + uci_set network "mesh_${radio}" mtu '1528' + uci_set network "mesh_${radio}" mesh 'bat0' + + uci_add wireless 'wifi-iface' "mesh_${radio}" + uci_set wireless "mesh_${radio}" device "$radio" + uci_set wireless "mesh_${radio}" network "mesh_${radio}" + uci_set wireless "mesh_${radio}" mode 'adhoc' + uci_set wireless "mesh_${radio}" ssid "$mesh_ssid" + uci_set wireless "mesh_${radio}" bssid "$mesh_bssid" + uci_set wireless "mesh_${radio}" mcast_rate "$mesh_mcast_rate" +} + +config_foreach configure_radio 'wifi-device' +uci_commit wireless +uci_commit network diff --git a/package/gluon-mesh-vpn-fastd/fastd.pl b/package/gluon-mesh-vpn-fastd/fastd.pl index 85bc7e28f..dd2f64ed4 100644 --- a/package/gluon-mesh-vpn-fastd/fastd.pl +++ b/package/gluon-mesh-vpn-fastd/fastd.pl @@ -55,5 +55,11 @@ EOF print <<END; commit fastd + +set network.mesh_vpn='interface' +set network.mesh_vpn.ifname='mesh-vpn' +set network.mesh_vpn.proto='batadv' +set network.mesh_vpn.mesh='bat0' +commit network EOF END -- GitLab