contrib/meshwizard: Add initial support for ipv6 config (with auto-ipv6-ib and dhcpv6)
authorManuel Munz <freifunk@somakoma.de>
Sat, 2 Jun 2012 20:44:58 +0000 (20:44 +0000)
committerManuel Munz <freifunk@somakoma.de>
Sat, 2 Jun 2012 20:44:58 +0000 (20:44 +0000)
contrib/package/meshwizard/Makefile
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/gen_auto-ipv6-dhcpv6-ip.sh [new file with mode: 0755]
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_auto-ipv6.sh [new file with mode: 0755]
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dnsmasq.sh
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_lan_ipv6.sh [new file with mode: 0755]
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_olsrd.sh
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_uhttpd.conf [new file with mode: 0755]
contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh

index 8cebf17..73f0185 100644 (file)
@@ -4,7 +4,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=meshwizard
-PKG_RELEASE:=0.0.6
+PKG_RELEASE:=0.0.7
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/gen_auto-ipv6-dhcpv6-ip.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/gen_auto-ipv6-dhcpv6-ip.sh
new file mode 100755 (executable)
index 0000000..e10677c
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+local PREFIX="$(echo $profile_ipv6_prefix| cut -d "/" -f 1| sed 's/::/:/')"
+local MAC="$(ifconfig $1 |grep HWaddr | awk '{ print $5 '})"
+local IPV6_UNIQ="$(echo $MAC | awk -F: '{ print $1$2":"$3$4":"$5$6 }')"
+
+echo "${PREFIX}${IPV6_UNIQ}:1"
+
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_auto-ipv6.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_auto-ipv6.sh
new file mode 100755 (executable)
index 0000000..edbbbc4
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+. $dir/functions.sh
+
+# Setup auto-ipv6
+
+if [ "$profile_ipv6_config" = "auto-ipv6-dhcpv6" ]; then
+       uci set autoipv6.olsr_node.enable=1
+       uci_commitverbose "Setup auto-ipv6 for dhcpv6 mode" autoipv6
+fi
+
+       
+
index 2b32f24..504aaee 100755 (executable)
@@ -21,6 +21,9 @@ EOF
 config_get addnhosts dnsmasq addnhosts
 if [ -z "${addnhosts/\var\/etc\/hosts.olsr/}" ]; then
        uci add_list dhcp.dnsmasq.addnhosts="/var/etc/hosts.olsr"
+       if [ "$profile_ipv6" = 1 ]; then
+               uci add_list dhcp.dnsmasq.addnhosts="/var/etc/hosts.olsr.ipv6"
+       fi
 fi
 
 uci_commitverbose "Setup dnsmasq" dhcp
index 36455a7..e14a384 100755 (executable)
@@ -97,4 +97,16 @@ for config in freifunk profile_$community; do
                config_foreach handle_firewall $section
        done
 done
+
+# If we use auto-ipv6-dhcp then allow 547/udp on the freifunk zone
+if [ "$profile_ipv6_config" = "auto-ipv6-dhcpv6" ]; then
+       uci batch <<- EOF
+               firewall.dhcpv6=rule
+               firewall.dhcpv6.src=freifunk
+               firewall.dhcpv6.target=ACCEPT
+               firewall.dhcpv6.dest_port=547
+               firewall.dhcpv6.proto=udp
+       EOF
+fi
+
 uci_commitverbose "Setup rules, forwardings, advanced config and includes." firewall
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_lan_ipv6.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_lan_ipv6.sh
new file mode 100755 (executable)
index 0000000..00f0706
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+[ ! "$(uci -q get network.lan)" == "interface" ] && exit
+
+. /etc/functions.sh
+. $dir/functions.sh
+
+# Setup IPv6 for the lan interface
+
+local ip6addr=""
+if [ "$profile_ipv6_config" = "auto-ipv6-dhcpv6" ]; then
+       # get lan mac
+       local device="$(uci -p/var/state -q get network.lan.ifname)"
+       if [ -n "device" ]; then
+               ip6addr="$($dir/helpers/gen_auto-ipv6-dhcpv6-ip.sh $device)"
+       fi
+       uci set network.lan.ip6addr="${ip6addr}/112"
+fi
+
+uci_commitverbose "Setup ipv6 address for lan" network
index 1215c95..fc3ca9d 100755 (executable)
@@ -23,6 +23,19 @@ uci batch << EOF
        set network.$netrenamed.netmask="$netmask"
 EOF
 
+# Setup IPv6 for the interface
+local ip6addr
+if [ "$profile_ipv6" = 1 ]; then
+       if [ "$profile_ipv6_config" = "auto-ipv6-dhcpv6" ]; then
+               # get interface mac
+               local device="$(uci -p/var/state -q get network.$netrenamed.ifname)"
+               if [ -n "device" ]; then
+                       ip6addr="$($dir/helpers/gen_auto-ipv6-dhcpv6-ip.sh $device)"
+               fi
+               uci set network.$netrenamed.ip6addr="${ip6addr}/112"
+       fi
+fi
+
 uci_commitverbose "Setup interface $netrenamed" network
 
 # setup dhcp alias/interface
index 10b1aff..f7ba95e 100755 (executable)
@@ -4,16 +4,30 @@
 . /etc/functions.sh
 . $dir/functions.sh
 
-# Rename interface defaults
+#Rename olsrd basic settings
+handle_olsrd() {
+       if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
+               section_rename olsrd $1 olsrd
+       fi
+}
+config_load olsrd
+config_foreach handle_olsrd olsrd
 
+# Rename interface defaults
 handle_interfacedefaults() {
        if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
                section_rename olsrd $1 InterfaceDefaults
        fi
 }
-config_load olsrd
 config_foreach handle_interfacedefaults InterfaceDefaults
 
+# Set basic olsrd settings
+if [ "profile_ipv6" = 1 ]; then
+       uci set olsrd.olsrd.IpVersion="6and4"
+fi
+uci_commitverbose "Setup olsr basic settings" olsrd
+
+
 # Setup new InterfaceDefaults
 uci set olsrd.InterfaceDefaults=InterfaceDefaults
 set_defaults "olsr_interfacedefaults_" olsrd.InterfaceDefaults
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_uhttpd.conf b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_uhttpd.conf
new file mode 100755 (executable)
index 0000000..0ab19ae
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+. $dir/functions.sh
+
+if [ "$profile_ipv6" = 1 ]; then
+       uci batch <<- EOF
+               set uhttpd.main.listen_http=":80"
+               set uhttpd.main.listen_https=:"443"
+       EOF
+fi
+
+uci_commitverbose "Setup uhttpd" uhttpd
+
index f58253b..33ef0b0 100755 (executable)
@@ -12,7 +12,7 @@
 . /etc/functions.sh
 
 echo "
-/* Meshwizard 0.0.4 */
+/* Meshwizard 0.0.7 */
 "
 
 # config
@@ -67,6 +67,14 @@ if [ "$lan_proto" == "static" ] && [ -n "$lan_ip4addr" ] && [ -n "$lan_netmask"
        $dir/helpers/setup_lan_static.sh
 fi
 
+if [ "$profile_ipv6" == 1 ]; then
+       $dir/helpers/setup_lan_ipv6.sh
+       # Setup auto-ipv6
+       if [ "$profile_ipv6_config" = "auto-ipv6-dhcpv6" ]; then
+               $dir/helpers/setup_auto-ipv6.sh
+       fi
+fi
+
 # Setup policyrouting if internet sharing is disabled and wan is not used for olsrd
 # Always disable it first to make sure its disabled when the user decied to share his internet
 uci set freifunk-policyrouting.pr.enable=0