Hearing no objections (:-), I decided to go ahead with this effort.
I have created a script named /etc/rc.ifsgl, which is invoked by
(the FreeBSD 4.7 RELEASE version of) /etc/rc.network, as follows:

183a184,185
         . /etc/rc.ifsgl      # handle sgl_ifconfig variable (etc).

That is, just before the lines:

        dhcp_interfaces=""
        for ifn in ${network_interfaces}; do
        ...

The relevant lines in rc.conf look like:

===
sgl_ifconfig="       inet 192.168.254.193 netmask 255.255.255.0"
sgl_ifconfig_alias0="inet 192.168.254.199 netmask 255.255.255.255"
===

The script itself looks like this:

===
:
# rc.ifsgl - handle sgl_ifconfig and sgl_ifconfig_aliasN variables
#
#  Sourced by rc.network; sets ifconfig_XX0 variable if sgl_ifconfig is set
#  and exactly one "link" interface has been detected.  Also adds aliases,
#  as defined by sgl_ifconfig_aliasN variables.
#
# Written by Rich Morin, CFCL, 2002.11

# set -x                                                                # DEBUG

# sgl_ifconfig="       inet 192.168.254.193 netmask 255.255.255.0"      # DEBUG
# sgl_ifconfig_alias0="inet 192.168.254.199 netmask 255.255.255.255"    # DEBUG

# LOG=/tmp/rc.ifsgl.log                                                 # DEBUG

for once in aboot; do
  if [ "$sgl_ifconfig" ]; then
    ifns=`ifconfig -l link`
    if [ ! "$ifns" ]; then
      echo "rc.ifsgl: no 'link' interfaces found."
      break
    fi
#   echo "ifns=|$ifns|" > /tmp/rc.ifsgl.log                             # DEBUG

    cnt=
    for ifn in $ifns; do
      eval test=\$ifconfig_${ifn}
      if [ "$test" ]; then
        echo "rc.ifsgl: interface ($ifn) already defined."
        break
      fi
      cnt=".$cnt"
    done
    if [ "$test" ]; then
      break
    fi

    if [ "$cnt" != '.' ]; then
      echo "rc.ifsgl: more than one interface found."
      break
    fi

    eval ifconfig_${ifn}=\$sgl_ifconfig

#        echo "VAR: ifconfig_${ifn}"   >> $LOG                          # DEBUG
#   eval echo "VAL: \$ifconfig_${ifn}" >> $LOG                          # DEBUG

    alias=0
    while : ; do
      eval test=\$sgl_ifconfig_alias${alias}
      if [ ! "$test" ]; then
        break
      fi

      eval ifconfig_${ifn}_alias${alias}=\$test
#          echo "VAR: ifconfig_${ifn}_alias${alias}"   >> $LOG          # DEBUG
#     eval echo "VAL: \$ifconfig_${ifn}_alias${alias}" >> $LOG          # DEBUG
      alias=$((${alias} + 1))
    done

  fi
done

# set +x
===

I am currently using this setup on my production machine, so I guess I'm
pretty confident that it's doing what _I_ need correctly.  I'm not at all
sure, however, that I'm taking every other possible system configuration
into account.  So, again, comments are solicited...

-r
--
email: [EMAIL PROTECTED]; phone: +1 650-873-7841
http://www.cfcl.com/rdm    - my home page, resume, etc.
http://www.cfcl.com/Meta   - The FreeBSD Browser, Meta Project, etc.
http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series
http://www.ptf.com/tdc     - Prime Time Freeware's Darwin Collection

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to