#!/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)"
# 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
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
. $dir/functions.sh
-if [ "$profile_ipv6_config" = "auto-ipv6-fromv4" ]; then
+if [ "$ipv6_config" = "auto-ipv6-fromv4" ]; then
mode="fromv4"
else
mode="random"
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
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
# 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
# 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
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
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
+++ /dev/null
-#!/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
-
--- /dev/null
+#!/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
+
#!/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
$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
$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
$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