Hi,

As you know bootpc only grabs information and works well if the
interface is up and added on the routing table as a default.  On the
other hand, ifup just executes bootpc without calling ifconfig and route
to get the interface up.  If the pre-up command is used to bring it up
before running bootpc, it will fetch parameters from one's network and
do nothing else.  Most people would like to use the bootp method in
interfaces and not to use bootpc to fetch and show parameters.

So please rename /sbin/bootpc to /sbin/bootpc-bin and save the attached
script as /sbin/bootpc instead.

Thanks, Kohei
-- 
Kohei Tanaka <[EMAIL PROTECTED]>
Fuji Xerox Co.,Ltd.
#!/bin/sh
#
# script to initialize a network interface using bootp
#
# Copyright (C) 2008 by Fuji Xerox Co., Ltd. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# written by Kohei Tanaka <[EMAIL PROTECTED]>

INTERFACE=eth0

# load configuration file
[ -f /etc/default/bootpc ] && . /etc/default/bootpc

# to get the interface looping over arguments
while [ $# -ne 0 ]
do
        case $1 in
        --dev)  INTERFACE=$2
                break;;
        *)      shift
                continue;;
        esac
done
        
# up the interface for sending broadcast packet
ifconfig $INTERFACE up 0.0.0.0
route add default dev $INTERFACE

TMPFILE=`mktemp /tmp/bootpc.XXXXXX`

/sbin/bootpc-bin --dev $INTERFACE --returniffail --serverbcast > $TMPFILE
RET=$?
route del default
ifconfig $INTERFACE down
if [ $RET -ne 0 ]
then
        rm -rf $TMPFILE
        exit 1
fi

. $TMPFILE
rm -rf $TMPFILE

[ -z "$IPADDR" ] && exit 1

OPT_NETMASK=""
OPT_BROADCAST=""
if [ -n "$NETMASK" ]
then
        OPT_NETMASK="netmask $NETMASK"
fi
if [ -n "$BROADCAST" ]
then
        OPT_BROADCAST="broadcast $BROADCAST"
fi
ifconfig $INTERFACE $IPADDR $OPT_NETMASK $OPT_BROADCAST

# already added a route to the network.  just add default gateway.
for i in $GATEWAYS
do
        route add default gw $i
done

[ x"$SETDNS" == xno ] && exit 0
if [ -n "$DOMAIN" ] || [ -n "$DNSSRVS" ]
then
        mv -f /etc/resolv.conf /etc/resolv.conf.old
        if [ -n "$DOMAIN" ]
        then
                echo "search $DOMAIN" >> /etc/resolv.conf
        fi
        for i in $DNSSRVS
        do
                echo "nameserver $i" >> /etc/resolv.conf
        done
fi

Reply via email to