summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pc-sysinstall/backend/functions-networking.sh
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2011-06-28 06:26:03 +0000
committergrehan <grehan@FreeBSD.org>2011-06-28 06:26:03 +0000
commit2c6741be0f59191f2283eb268e4f7690399d578a (patch)
treeb139c8c6dcca4fa284815daade405b75886ee360 /usr.sbin/pc-sysinstall/backend/functions-networking.sh
parent3c35264f695e0a1f8a04dbcca1c93bb5159b2274 (diff)
parent19ae02bba572390c7299166228d31e54003e094a (diff)
downloadFreeBSD-src-2c6741be0f59191f2283eb268e4f7690399d578a.zip
FreeBSD-src-2c6741be0f59191f2283eb268e4f7690399d578a.tar.gz
IFC @ r222830
Diffstat (limited to 'usr.sbin/pc-sysinstall/backend/functions-networking.sh')
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-networking.sh195
1 files changed, 174 insertions, 21 deletions
diff --git a/usr.sbin/pc-sysinstall/backend/functions-networking.sh b/usr.sbin/pc-sysinstall/backend/functions-networking.sh
index d12a9cc..bdd5a1a 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-networking.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-networking.sh
@@ -1,6 +1,11 @@
#!/bin/sh
#-
# Copyright (c) 2010 iXsystems, Inc. All rights reserved.
+# Copyright (c) 2011 The FreeBSD Foundation
+# All rights reserved.
+#
+# Portions of this software were developed by Bjoern Zeeb
+# under sponsorship from the FreeBSD Foundation.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -119,6 +124,61 @@ save_auto_dhcp()
enable_dhcp_all
};
+# Function which simply enables iPv6 SLAAC on all detected nics
+enable_slaac_all()
+{
+ rm ${TMPDIR}/.niclist >/dev/null 2>/dev/null
+ # start by getting a list of nics on this system
+ ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist
+ if [ -e "${TMPDIR}/.niclist" ]
+ then
+ echo "# Auto-Enabled NICs from pc-sysinstall" >>${FSMNT}/etc/rc.conf
+ WLANCOUNT="0"
+ while read line
+ do
+ NIC="`echo $line | cut -d ':' -f 1`"
+ DESC="`echo $line | cut -d ':' -f 2`"
+ echo_log "Setting $NIC to acceptign RAs on the system."
+ check_is_wifi ${NIC}
+ if [ $? -eq 0 ]
+ then
+ # We have a wifi device, setup a wlan* entry for it
+ # Given we cannot have DHCP and SLAAC the same time currently
+ # it's save to just duplicate.
+ WLAN="wlan${WLANCOUNT}"
+ echo "wlans_${NIC}=\"${WLAN}\"" >>${FSMNT}/etc/rc.conf
+ #echo "ifconfig_${NIC}=\"up\"" >>${FSMNT}/etc/rc.conf
+ echo "ifconfig_${WLAN}=\"inet6 accept_rtadv\"" >>${FSMNT}/etc/rc.conf
+ CNIC="${WLAN}"
+ WLANCOUNT=$((WLANCOUNT+1))
+ else
+ #echo "ifconfig_${NIC}=\"up\"" >>${FSMNT}/etc/rc.conf
+ echo "ifconfig_${NIC}_ipv6=\"inet6 accept_rtadv\"" >>${FSMNT}/etc/rc.conf
+ CNIC="${NIC}"
+ fi
+
+ done < ${TMPDIR}/.niclist
+ fi
+
+ # Given we cannot yet rely on RAs to provide DNS information as much
+ # as we can in the DHCP world, we should append a given nameserver.
+ : > ${FSMNT}/etc/resolv.conf
+ get_value_from_cfg netSaveIPv6NameServer
+ NAMESERVER="${VAL}"
+ if [ -n "${NAMESERVER}" ]
+ then
+ echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf
+ fi
+
+};
+
+
+# Function which detects available nics, and enables IPv6 SLAAC on them
+save_auto_slaac()
+{
+ enable_slaac_all
+};
+
# Function which saves a manual nic setup to the installed system
save_manual_nic()
@@ -137,21 +197,41 @@ save_manual_nic()
fi
# If we get here, we have a manual setup, lets do so now
+ IFARGS=""
+ IF6ARGS=""
# Set the manual IP
- IFARGS="inet ${NETIP}"
-
- # Check if we have a netmask to set
- get_value_from_cfg netSaveMask
- NETMASK="${VAL}"
- if [ -n "${NETMASK}" ]
+ if [ -n "${NETIP}" ]
then
- IFARGS="${IFARGS} netmask ${NETMASK}"
+ IFARGS="inet ${NETIP}"
+
+ # Check if we have a netmask to set
+ get_value_from_cfg netSaveMask
+ NETMASK="${VAL}"
+ if [ -n "${NETMASK}" ]
+ then
+ IFARGS="${IFARGS} netmask ${NETMASK}"
+ fi
fi
+ get_value_from_cfg netSaveIPv6
+ NETIP6="${VAL}"
+ if [ -n "${NETIP6}" ]
+ then
+ # Make sure we have one inet6 prefix.
+ IF6ARGS=`echo "${NETIP6}" | awk '{ if ("^inet6 ") { print $0; } else
+ { printf "inet6 %s", $0; } }'`
+ fi
echo "# Auto-Enabled NICs from pc-sysinstall" >>${FSMNT}/etc/rc.conf
- echo "ifconfig_${NIC}=\"${IFARGS}\"" >>${FSMNT}/etc/rc.conf
+ if [ -n "${IFARGS}" ]
+ then
+ echo "ifconfig_${NIC}=\"${IFARGS}\"" >>${FSMNT}/etc/rc.conf
+ fi
+ if [ -n "${IF6ARGS}" ]
+ then
+ echo "ifconfig_${NIC}_ipv6=\"${IF6ARGS}\"" >>${FSMNT}/etc/rc.conf
+ fi
# Check if we have a default router to set
get_value_from_cfg netSaveDefaultRouter
@@ -160,15 +240,28 @@ save_manual_nic()
then
echo "defaultrouter=\"${NETROUTE}\"" >>${FSMNT}/etc/rc.conf
fi
+ get_value_from_cfg netSaveIPv6DefaultRouter
+ NETROUTE="${VAL}"
+ if [ -n "${NETROUTE}" ]
+ then
+ echo "ipv6_defaultrouter=\"${NETROUTE}\"" >>${FSMNT}/etc/rc.conf
+ fi
# Check if we have a nameserver to enable
+ : > ${FSMNT}/etc/resolv.conf
get_value_from_cfg netSaveNameServer
NAMESERVER="${VAL}"
if [ -n "${NAMESERVER}" ]
then
- echo "nameserver ${NAMESERVER}" >${FSMNT}/etc/resolv.conf
+ echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf
fi
-
+ get_value_from_cfg netSaveIPv6NameServer
+ NAMESERVER="${VAL}"
+ if [ -n "${NAMESERVER}" ]
+ then
+ echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf
+ fi
+
};
# Function which determines if a nic is active / up
@@ -208,6 +301,31 @@ enable_auto_dhcp()
};
+# Function which detects available nics, and runs rtsol on them.
+enable_auto_slaac()
+{
+
+ # start by getting a list of nics on this system
+ ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist
+ ALLNICS=""
+ while read line
+ do
+ NIC="`echo $line | cut -d ':' -f 1`"
+ DESC="`echo $line | cut -d ':' -f 2`"
+
+ is_nic_active "${NIC}"
+ if [ $? -eq 0 ] ; then
+ echo_log "Will try IPv6 SLAAC on $NIC $DESC"
+ ifconfig ${NIC} inet6 -ifdisabled accept_rtadv up
+ ALLNICS="${ALLNICS} ${NIC}"
+ fi
+ done < ${TMPDIR}/.niclist
+
+ # XXX once we support it in-tree call /sbin/resovconf here.
+ echo_log "Running rtsol on ${ALLNICS}"
+ rtsol -F ${ALLNICS} >/dev/null 2>/dev/null
+}
+
# Get the mac address of a target NIC
get_nic_mac()
{
@@ -236,15 +354,20 @@ enable_manual_nic()
# If we get here, we have a manual setup, lets do so now
- # Set the manual IP
- rc_halt "ifconfig ${NIC} ${NETIP}"
+ # IPv4:
- # Check if we have a netmask to set
- get_value_from_cfg netMask
- NETMASK="${VAL}"
- if [ -n "${NETMASK}" ]
+ # Set the manual IP
+ if [ -n "${NETIP}" ]
then
- rc_halt "ifconfig ${NIC} netmask ${NETMASK}"
+ # Check if we have a netmask to set
+ get_value_from_cfg netMask
+ NETMASK="${VAL}"
+ if [ -n "${NETMASK}" ]
+ then
+ rc_halt "ifconfig inet ${NIC} netmask ${NETMASK}"
+ else
+ rc_halt "ifconfig inet ${NIC} ${NETIP}"
+ fi
fi
# Check if we have a default router to set
@@ -252,18 +375,42 @@ enable_manual_nic()
NETROUTE="${VAL}"
if [ -n "${NETROUTE}" ]
then
- rc_halt "route add default ${NETROUTE}"
+ rc_halt "route add -inet default ${NETROUTE}"
+ fi
+
+ # IPv6:
+
+ # Set static IPv6 address
+ get_value_from_cfg netIPv6
+ NETIP="${VAL}"
+ if [ -n ${NETIP} ]
+ then
+ rc_halt "ifconfig inet6 ${NIC} ${NETIP} -ifdisabled up"
+ fi
+
+ # Default router
+ get_value_from_cfg netIPv6DefaultRouter
+ NETROUTE="${VAL}"
+ if [ -n "${NETROUTE}" ]
+ then
+ rc_halt "route add -inet6 default ${NETROUTE}"
fi
# Check if we have a nameserver to enable
+ : >/etc/resolv.conf
get_value_from_cfg netNameServer
NAMESERVER="${VAL}"
if [ -n "${NAMESERVER}" ]
then
- echo "nameserver ${NAMESERVER}" >/etc/resolv.conf
+ echo "nameserver ${NAMESERVER}" >>/etc/resolv.conf
fi
-
-
+ get_value_from_cfg netIPv6NameServer
+ NAMESERVER="${VAL}"
+ if [ -n "${NAMESERVER}" ]
+ then
+ echo "nameserver ${NAMESERVER}" >>/etc/resolv.conf
+ fi
+
};
@@ -281,6 +428,9 @@ start_networking()
if [ "$NETDEV" = "AUTO-DHCP" ]
then
enable_auto_dhcp
+ elif [ "$NETDEV" = "IPv6-SLAAC" ]
+ then
+ enable_auto_slaac
else
enable_manual_nic ${NETDEV}
fi
@@ -304,6 +454,9 @@ save_networking_install()
if [ "$NETDEV" = "AUTO-DHCP" ]
then
save_auto_dhcp
+ elif [ "$NETDEV" = "IPv6-SLAAC" ]
+ then
+ save_auto_slaac
else
save_manual_nic ${NETDEV}
fi
OpenPOWER on IntegriCloud