[PC-BSD Commits] r4865 - in pcbsd/trunk/pc-sysinstall: . backend
svn at pcbsd.org
svn at pcbsd.org
Wed Nov 4 09:10:58 PST 2009
Author: kris
Date: 2009-11-04 09:10:58 -0800 (Wed, 04 Nov 2009)
New Revision: 4865
Modified:
pcbsd/trunk/pc-sysinstall/backend/functions-networking.sh
pcbsd/trunk/pc-sysinstall/backend/parseconfig.sh
pcbsd/trunk/pc-sysinstall/pcinstall.cfg
Log:
Added support for saving a supplied networking config to the installed system
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-networking.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-networking.sh 2009-11-04 16:44:16 UTC (rev 4864)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-networking.sh 2009-11-04 17:10:58 UTC (rev 4865)
@@ -1,6 +1,82 @@
#!/bin/sh
# Functions which perform our networking setup
+# Function which detects available nics, and runs sets them to DHCP on the
+# system
+save_auto_dhcp()
+{
+ 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
+
+ while read line
+ do
+ NIC="`echo $line | cut -d ':' -f 1`"
+ DESC="`echo $line | cut -d ':' -f 2`"
+ echo_log "Setting $NIC to DHCP on the system."
+ echo "ifconfig_${NIC}=\"DHCP\"" >>${FSMNT}/etc/rc.conf
+ done < ${TMPDIR}/.niclist
+ fi
+
+};
+
+
+# Function which saves a manual nic setup to the installed system
+save_manual_nic()
+{
+ # Get the target nic
+ NIC="$1"
+
+ get_value_from_cfg netSaveIP
+ NETIP="${VAL}"
+
+ if [ "$NETIP" = "DHCP" ]
+ then
+ echo_log "Setting $NIC to DHCP on the system."
+ echo "ifconfig_${NIC}=\"DHCP\"" >>${FSMNT}/etc/rc.conf
+ return 0
+ fi
+
+ # If we get here, we have a manual setup, lets do so now
+
+ # Set the manual IP
+ IFARGS="inet ${NETIP}"
+
+ # Check if we have a netmask to set
+ get_value_from_cfg netSaveMask
+ NETMASK="${VAL}"
+ if [ ! -z "${NETMASK}" ]
+ then
+ IFARGS="${IFARGS} netmask ${NETMASK}"
+ fi
+
+
+ echo "# Auto-Enabled NICs from pc-sysinstall" >>${FSMNT}/etc/rc.conf
+ echo "ifconfig_${NIC}=\"${IFARGS}\"" >>${FSMNT}/etc/rc.conf
+
+ # Check if we have a default router to set
+ get_value_from_cfg netSaveDefaultRouter
+ NETROUTE="${VAL}"
+ if [ ! -z "${NETROUTE}" ]
+ then
+ echo "defaultrouter=\"${NETROUTE}\"" >>${FSMNT}/etc/rc.conf
+ fi
+
+ # Check if we have a nameserver to enable
+ get_value_from_cfg netSaveNameServer
+ NAMESERVER="${VAL}"
+ if [ ! -z "${NAMESERVER}" ]
+ then
+ echo "nameserver ${NAMESERVER}" >${FSMNT}/etc/resolv.conf
+ fi
+
+};
+
+
# Function which detects available nics, and runs DHCP on them until
# a success is found
enable_auto_dhcp()
@@ -22,6 +98,7 @@
};
+
# Function which performs the manual setup of a target nic in the cfg
enable_manual_nic()
{
@@ -73,6 +150,7 @@
};
+
# Function which parses the cfg and enables networking per specified
start_networking()
{
@@ -92,3 +170,27 @@
fi
};
+
+
+# Function which checks the cfg and enables the specified networking on
+# the installed system
+save_networking_install()
+{
+
+ # Check if we have any networking requested to save
+ get_value_from_cfg netSaveDev
+ if [ -z "${VAL}" ]
+ then
+ return 0
+ fi
+
+ NETDEV="${VAL}"
+ if [ "$NETDEV" = "AUTO-DHCP" ]
+ then
+ save_auto_dhcp
+ else
+ save_manual_nic ${NETDEV}
+ fi
+
+};
+
Modified: pcbsd/trunk/pc-sysinstall/backend/parseconfig.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/parseconfig.sh 2009-11-04 16:44:16 UTC (rev 4864)
+++ pcbsd/trunk/pc-sysinstall/backend/parseconfig.sh 2009-11-04 17:10:58 UTC (rev 4865)
@@ -100,6 +100,9 @@
# Do any localization in configuration
run_localize
+ # Save any networking config on the installed system
+ save_networking_install
+
# Do any last cleanup / setup before unmounting
run_final_cleanup
Modified: pcbsd/trunk/pc-sysinstall/pcinstall.cfg
===================================================================
--- pcbsd/trunk/pc-sysinstall/pcinstall.cfg 2009-11-04 16:44:16 UTC (rev 4864)
+++ pcbsd/trunk/pc-sysinstall/pcinstall.cfg 2009-11-04 17:10:58 UTC (rev 4865)
@@ -23,10 +23,17 @@
netDev=AUTO-DHCP
#netDev=nfe0
#netIP=192.168.0.49
+#netMask=255.255.255.0
#netNameServer=208.67.222.222
#netDefaultRouter=192.168.0.1
-#netMask=255.255.255.0
+netSaveDev=AUTO-DHCP
+#netSaveDev=nfe0
+#netSaveIP=192.168.0.49
+#netSaveMask=255.255.255.0
+#netSaveNameServer=208.67.222.222
+#netSaveDefaultRouter=192.168.0.1
+
# Set if we are installing via optical, USB, or FTP
installType=PCBSD
installMedium=dvd
More information about the Commits
mailing list