meshwizard: ipv6 fixes, fix uhttpd setup

This commit is contained in:
Manuel Munz 2012-08-15 12:33:33 +00:00
parent e627e614d8
commit 366c3cd9cc
12 changed files with 38 additions and 17 deletions

View file

@ -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)"

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,7 +1,6 @@
#!/bin/sh
. $dir/functions.sh
if [ "$profile_ipv6" = 1 ]; then
if [ "$ipv6_enabled" = "1" ]; then
uci batch <<- EOF
set uhttpd.main.listen_http=":80"
set uhttpd.main.listen_https=:"443"

View file

@ -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

View file

@ -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