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 114c8f9c11a008e98ce2e4377c23270432675121..ca623dbcab80ac777eff783d72cbeeb3fcef5e24 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 f5b4943b8f687bd3c47df3a230a501df7af6e4b7..fe8410116a76e3eea7ba2a4093afe8fcd12ac39c 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 5be4a3e61b719449b9b82d054ef885f7d43f6dea..8e3f015cde99768c2af1f38c0e33f296036e2889 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 59b7f845b0c5bc734bcd568ea963939e3fc29a11..9297f9175edcbf9f25bc9f399039886cad38d346 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 7eceb508836eaf37e03f35b073161ce89413feef..bf47241122af4a079bb3c2d4b7ed995f23461ec4 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 1b6e0dee38b1f28c076085f16b6e1498b722be5f..2f6144b67ffb4871cd56e08c9d4762e9cafea955 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 8c909e2d5fc497387f1f88eb889a673efef05681..325475fa6ebffcf9acc815ea4e42898748478cf1 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 2d9e74c7bd9858c7cd5a526c93578a91d25cfacf..f97aad6f47d7bb82d82cc1ad4ec24a9ae8507fac 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 6bb490adfb4f320ae5e8c6fda1a4fff467a48769..edb5eea434fac945861de0e21e83483451b8eea6 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 98b941b84ae2dad19edbbb8d8a708760d957886f..91fc1d8dab6464b7ee2238611a9e5f5d13c1a780 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 f6b227dceb3e32c0353219f267c3451730162424..41a6117ea0c889c81c73643509db006878bd3170 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