From owner-svn-src-head@FreeBSD.ORG Wed Oct 21 13:25:25 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A9C4106566B; Wed, 21 Oct 2009 13:25:25 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 550ED8FC1E; Wed, 21 Oct 2009 13:25:25 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id DC73B46B0C; Wed, 21 Oct 2009 09:25:24 -0400 (EDT) Received: from jhbbsd.hudson-trading.com (unknown [209.249.190.8]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 1229C8A025; Wed, 21 Oct 2009 09:25:24 -0400 (EDT) From: John Baldwin To: Rink Springer Date: Wed, 21 Oct 2009 09:13:11 -0400 User-Agent: KMail/1.9.7 References: <200910211110.n9LBAYG6097426@svn.freebsd.org> In-Reply-To: <200910211110.n9LBAYG6097426@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200910210913.12038.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Wed, 21 Oct 2009 09:25:24 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r198317 - head/usr.sbin/sysinstall X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Oct 2009 13:25:25 -0000 On Wednesday 21 October 2009 7:10:34 am Rink Springer wrote: > Author: rink > Date: Wed Oct 21 11:10:34 2009 > New Revision: 198317 > URL: http://svn.freebsd.org/changeset/base/198317 > > Log: > Introduce 'netDev=ANY' support for scripted (install.cfg) installs, which results in the first ethernet interface with physical link being selected. > > While here, fix a minor typo causing an 'if' to be missed. > > Submitted by: randi Note that in the case of PXE you can use a shell script to automatically use the PXE interface. I do this in my scripts here at work. install.cfg contains: # Figure out our installation media and configure it. command=/bin/sh /stand/domedia.sh system configFile=/stand/media.cfg loadConfig And domedia.sh contains this code to figure out which network interface to use if a kernel environment variable is set to indicate an NFS install (vs a CD install, the scripts support both) (Note that I have added kenv and dialog to my mfsroot): #!/bin/sh # # Figure out which install media we want to use. netif=`kenv -q install.netif` nfspath=`kenv -q install.nfspath` # Determine if a given network interface has link # XXX: some drivers only report link if the interface is UP netif_up() { local status status=`ifconfig $1 | sed -ne '/status:/p'` case $status in *active*) return 0 ;; esac return 1 } # Returns true if a given network interface has the specified MAC address. macmatch() { local addr addr=`ifconfig $1 | sed -ne '/ ether /{s///;p;}'` [ "$addr" = "$2" ] return $? } # If 'nfspath' is set, assume we are using NFS, otherwise, assume we # are installing from a CD. if [ -n "${nfspath}" ]; then # If netif isn't set, try to guess at a sane value. if [ -z "${netif}" ]; then # This is set by the loader when booting via PXE macaddr=`kenv -q boot.netif.hwaddr` macif="" count=0 upcount=0 ifaces="" upifaces="" for ifn in `ifconfig -l`; do case $ifn in lo0) # Ignore loopback ;; *) count=$((count + 1)) ifaces="${ifaces} ${ifn}" if netif_up $ifn; then upcount=$((upcount + 1)) upifaces="${upifaces} ${ifn}" fi if [ -n "$macaddr" ] && \ macmatch $ifn $macaddr; then macif="$ifn" fi ;; esac done # If there is only a single interface, use that. If # we booted via PXE and the MAC address for PXE # matches the MAC address of an interface, use that. # Finally, if only one interface has link, use that. # If all of those tests fail, pop up a menu. if [ $count -eq 1 ]; then # The echo trims extra spaces netif=`echo $ifaces` elif [ -n "$macif" ]; then netif="$macif" elif [ $upcount -eq 1 ]; then # The echo trims extra spaces netif=`echo $upifaces` else # Build the menu ifmenu="" for ifn in $ifaces; do ifmenu="${ifmenu} ${ifn} Network" done # Run the menu while [ -z "${netif}" ]; do rm -f /stand/netif dialog --menu "Select the network interface to use for NFS." \ $((count + 7)) 50 $((count)) ${ifmenu} 2> \ /stand/netif if [ $? -eq 0 ]; then netif=`cat /stand/netif` fi done fi fi cat > /stand/media.cfg < /stand/media.cfg <