meshwizard: ipv6 fixes, fix uhttpd setup
authorManuel Munz <freifunk@somakoma.de>
Wed, 15 Aug 2012 12:33:33 +0000 (12:33 +0000)
committerManuel Munz <freifunk@somakoma.de>
Wed, 15 Aug 2012 12:33:33 +0000 (12:33 +0000)
13 files changed:
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/gen_auto-ipv6-dhcpv6-ip.sh
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/read_defaults.sh
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_auto-ipv6.sh
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
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_olsrd_interface.sh
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_uhttpd.conf [deleted file]
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_uhttpd.sh [new file with mode: 0755]
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wan_dhcp.sh
contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh

index 114c8f9..ca623db 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 netrenamed=$1
 
-local PREFIX="$(echo $profile_ipv6_prefix| cut -d "/" -f 1| sed 's/::/:/')"
+local PREFIX="$(echo $ipv6_prefix| cut -d "/" -f 1| sed 's/::/:/')"
 
 # Get the devices mac address
 local device="$(uci -p/var/state -q get network.$1.ifname)"
index f5b4943..fe84101 100755 (executable)
@@ -6,7 +6,7 @@ community="$1"
 
 # reads variables from uci files, parameter $1 is the section
 get_var() {
-       uci -q show $1 | cut -d "." -f 2-100 |grep "\." | sed -e 's/^\([a-z_]*\)\./\1_/g' -e 's/=\(.*\)$/="\1"/g'
+       uci -q show $1 | cut -d "." -f 2-100 |grep "\." | sed -e 's/^\([A-Za-z0-9_]*\)\./\1_/g' -e 's/=\(.*\)$/="\1"/g'
 }
 
 # read default values from /etc/config/freifunk
@@ -15,11 +15,11 @@ for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_
 done
 
 # now read all values from the selected community profile, will override some values from the defaults before
-for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_interfacedefaults profile zone_freifunk include luci_splash; do
+for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_interfacedefaults profile zone_freifunk include luci_splash ipv6; do
        get_var profile_$community.$v
 done
 
 # read values from meshwizard
-for v in system luci_main contact community wan lan general; do
+for v in system luci_main contact community wan lan general ipv6; do
         get_var meshwizard.$v
 done
index 5be4a3e..8e3f015 100755 (executable)
@@ -2,7 +2,7 @@
 
 . $dir/functions.sh
 
-if [ "$profile_ipv6_config" = "auto-ipv6-fromv4" ]; then
+if [ "$ipv6_config" = "auto-ipv6-fromv4" ]; then
        mode="fromv4"
 else
        mode="random"
index 59b7f84..9297f91 100755 (executable)
@@ -21,7 +21,7 @@ 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
+       if [ "$ipv6_enabled" = 1 ]; then
                uci add_list dhcp.dnsmasq.addnhosts="/var/etc/hosts.olsr.ipv6"
        fi
 fi
index 7eceb50..bf47241 100755 (executable)
@@ -99,7 +99,7 @@ for config in freifunk profile_$community; do
 done
 
 # If we use auto-ipv6-dhcp then allow 547/udp on the freifunk zone
-if [ "$profile_ipv6_config" = "auto-ipv6-dhcpv6" ]; then
+if [ "$ipv6_config" = "auto-ipv6-dhcpv6" ]; then
        uci batch <<- EOF
                set firewall.dhcpv6=rule
                set firewall.dhcpv6.src=freifunk
index 1b6e0de..2f6144b 100755 (executable)
@@ -8,7 +8,7 @@
 # Setup IPv6 for the lan interface
 
 local ip6addr=""
-if [ "$profile_ipv6_config" = "auto-ipv6-dhcpv6" ]; then
+if [ "$ipv6_config" = "auto-ipv6-dhcpv6" ]; then
        # get lan mac
        local device="$(uci -p/var/state -q get network.lan.ifname)"
        if [ -n "device" ]; then
index 8c909e2..325475f 100755 (executable)
@@ -26,12 +26,12 @@ EOF
 
 # Setup IPv6 for the interface
 local ip6addr
-if [ "$profile_ipv6" = 1 ]; then
-       if [ "$profile_ipv6_config" = "auto-ipv6-dhcpv6" ]; then
+if [ "$ipv6_enabled" = 1 ]; then
+       if [ "$ipv6_config" = "auto-ipv6-dhcpv6" ]; then
                ip6addr="$($dir/helpers/gen_auto-ipv6-dhcpv6-ip.sh $netrenamed)"
                uci set network.$netrenamed.ip6addr="${ip6addr}/112"
        fi
-       if [ "$profile_ipv6_config" = "static" ] && [ -n "$ip6addr" ]; then
+       if [ "$ipv6_config" = "static" ] && [ -n "$ip6addr" ]; then
                uci set network.$netrenamed.ip6addr="$ip6addr"
        fi
 fi
index 2d9e74c..f97aad6 100755 (executable)
@@ -31,7 +31,7 @@ handle_interfacedefaults() {
 config_foreach handle_interfacedefaults InterfaceDefaults
 
 # Set basic olsrd settings
-if [ "$profile_ipv6" = 1 ] && [ "$has_ipv6" == "1" ]; then
+if [ "$ipv6_enabled" = 1 ] && [ "$has_ipv6" == "1" ]; then
        uci set olsrd.olsrd.IpVersion="6and4"
 fi
 
index 6bb490a..edb5eea 100755 (executable)
@@ -44,3 +44,17 @@ if [ -n "$dhcprange" ]; then
                uci_commitverbose "Setup HNA for network $dhcprange" olsrd
        fi
 fi
+
+# Set Hna entry for ipv6 net for static ipv6 config
+uci -q delete olsrd.${netrenamed}static
+if [ "$ipv6_enabled" = "1" ] && [ "$ipv6_config" = "static" ]; then
+       local v6range="$(uci -q get meshwizard.netconfig.$net\_ip6addr)"
+       local v6net="$(echo $v6range | cut -d '/' -f 1)"
+       local v6mask="$(echo $v6range | cut -d '/' -f 2)"
+       if [ -n "$v6net" ] && [ -n "$v6mask" ]; then
+               uci set olsrd.${netrenamed}static="Hna6"
+               uci set olsrd.${netrenamed}static.netaddr="$v6net"
+               uci set olsrd.${netrenamed}static.prefix="$v6mask"
+               uci_commitverbose "Setup HNA for network $v6range" olsrd
+       fi
+fi
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
deleted file mode 100755 (executable)
index 0ab19ae..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/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
-
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_uhttpd.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_uhttpd.sh
new file mode 100755 (executable)
index 0000000..172e414
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+. $dir/functions.sh
+if [ "$ipv6_enabled" = "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 98b941b..91fc1d8 100755 (executable)
@@ -1,11 +1,18 @@
 #!/bin/sh
 # Setup dhcp interface settings for wan. This is the OpenWrt default,
 # so all we need to do here is to delete wan from meshwizard after setup.
+# Also disallow ra on wan if ipv6 is enabled
 
 [ ! "$(uci -q get network.wan)" == "interface" ] && exit
 
 . /lib/functions.sh
 . $dir/functions.sh
 
+if [ "$ipv6_enabled" = "1" ]; then
+       uci set network.wan.accept_ra='0'
+       uci_commitverbose "Do not accept ra on wan interface" network
+fi
+
+
 uci delete meshwizard.wan && uci commit meshwizard
 
index f6b227d..41a6117 100755 (executable)
@@ -60,6 +60,7 @@ $dir/helpers/setup_system.sh
 $dir/helpers/setup_olsrd.sh
 $dir/helpers/setup_firewall.sh
 $dir/helpers/setup_ssh.sh
+$dir/helpers/setup_uhttpd.sh
 
 if [ "$wan_proto" == "static" ] && [ -n "$wan_ip4addr" ] && [ -n "$wan_netmask" ]; then
        $dir/helpers/setup_wan_static.sh
@@ -73,10 +74,10 @@ if [ "$lan_proto" == "static" ] && [ -n "$lan_ip4addr" ] && [ -n "$lan_netmask"
        $dir/helpers/setup_lan_static.sh
 fi
 
-if [ "$profile_ipv6" == 1 ] && [ "$has_ipv6" = 1 ]; then
+if [ "$ipv6_enabled" == 1 ] && [ "$has_ipv6" = 1 ]; then
        $dir/helpers/setup_lan_ipv6.sh
        # Setup auto-ipv6
-       if [ -n "$(echo "$profile_ipv6_config" |grep auto-ipv6)" ]; then
+       if [ -n "$(echo "$ipv6_config" |grep auto-ipv6)" ]; then
                $dir/helpers/setup_auto-ipv6.sh
        fi
 fi
@@ -107,7 +108,7 @@ for net in $networks; do
        $dir/helpers/setup_splash.sh $net
        $dir/helpers/setup_firewall_interface.sh $net
 
-       if [ -n "$(echo "$profile_ipv6_config" |grep auto-ipv6)" ]; then
+       if [ -n "$(echo "$ipv6_config" |grep auto-ipv6)" ]; then
                $dir/helpers/setup_auto-ipv6-interface.sh $net
        fi
 done