Hey!
I am really liking this LFS system, it seems so much faster than the other distros.
I had a situation with dhcp so I added some stuff to the /etc/init.d/ethnet to take care of it
I saw someones hint for it but it was really not going to work because I have more than one nic, some of them dhcp, some static
anyway I am posting the file so anybody that don't have theirs fixed might like it.
ALL changes are clearly marked..
the timeout for dhcpcd can be up to 60 seconds, set it to what works best for you.
you will need to add one thing to the nics ifcfg file that you want to use dhcp on, like this
/etc/sysconfig/nic-config/ifcfg-eth0
BOOTPROTO=dhcp
make sure that dhcpcd is in the path or add the path to the scripts
There is a dhcpcd issue not pertaining to LFS but you need to be aware of it.
The files created by the dhcpcd daemon go into the /etc/dhcpc folder.
The install of dhcpcd will not create the folder so you will need to.
and here's the complete /etc/init.d/ethnet
#!/bin/sh
# Begin /etc/init.d/ethnet
#
# Main script by Gerard Beekmans -
gerard@linuxfromscratch.org
# GATEWAY check by Jean-François Le Ray -
jfleray@club-internet.fr
# "Specify which IF to use to reach default GATEWAY" by
# Graham Cantin -
gcantin@pacbell.net
# DHCPCD handled by
# David Phillips -
#
doodlebuggerr@hotmail.com
#
#------------------------------------------------------------
## Begin added code for dhcpcd
#___________________________________________
#
DHCP_TIMEOUT="10" #max 60 seconds
PROTOCOL="dhcp"
PID_DIR="/etc/dhcpc"
IF_CFG_DIR="/etc/sysconfig/nic-config"
#------------------------------------------------------------
# End added code for dhcpcd
#___________________________________________
#
# Include the functions declared in the /etc/init.d/functions file
# and the variables from the /etc/sysconfig/network file.
#
source /etc/init.d/functions
source /etc/sysconfig/network
case "$1" in
start)
#
# Obtain all the network card configuration files
#
for interface in $(/bin/ls /etc/sysconfig/nic-config/ifcfg* | \
grep -v ifcfg-lo)
do
#
# Load the variables from that file
#
source $interface
#-----------------------------------------------------------
## Begin added code for dhcpcd
#-----------------------------------------------------------
if [ "$BOOTPROTO" != "$PROTOCOL" ]
then
#-----------------------------------------------------------
## End added code for dhcpcd
#-----------------------------------------------------------
# If the ONBOOT variable is set to yes, process this file and bring the
# interface up.
#
if [ "$ONBOOT" == yes ]
then
echo -n "Bringing up the $DEVICE interface..."
/sbin/ifconfig $DEVICE $IP broadcast $BROADCAST \
netmask $NETMASK
evaluate_retval
fi
#-----------------------------------------------------------
## Begin added code for dhcpcd
#-----------------------------------------------------------
else
if [ "$BOOTPROTO" != "" ]
then
if ls $PID_DIR/dhcpcd-$DEVICE.pid 2>/dev/null
then
echo -n "file was found, if $DEVICE is down then try restart."
evaluate_retval
else
echo -n "Contacting a DHCP server for the $DEVICE interface..."
if dhcpcd -t $DHCP_TIMEOUT $DEVICE
then
evaluate_retval
else
evaluate_retval
fi
fi
fi
fi
BOOTPROTO=""
#-----------------------------------------------------------
# End added code for dhcpcd
#-----------------------------------------------------------
done
#
# If the /etc/sysconfig/network file contains a GATEWAY variable, set
# the default gateway and the interface through which the default
# gateway can be reached.
#
if [ "$GATEWAY" != "" ]; then
echo -n "Setting up routing for $GATEWAY_IF interface..."
/sbin/route add default gateway $GATEWAY \
metric 1 dev $GATEWAY_IF
evaluate_retval
fi
;;
stop)
#
# Obtain all the network card configuration files
#
for interface in $(/bin/ls /etc/sysconfig/nic-config/ifcfg* | \
grep -v ifcfg-lo)
do
#
# Load the variables from that file
#
source $interface
#
# If the ONBOOT variable is set, process the file and bring the
# interface down
#
if [ $ONBOOT == yes ]
then
echo -n "Bringing down the $DEVICE interface..."
/sbin/ifconfig $DEVICE down
#---------------------------------------------------------------
# Begin added code for dhcpcd
#---------------------------------------------------------------
if [ "$BOOTPROTO" = "$PROTOCOL" ]
then
if [ $BOOTPROTO != "" ]
then
dhcpcd -k $DEVICE 2>/dev/null
fi
fi
BOOTPROTO=""
#---------------------------------------------------------------
# End sdded code for dhcpcd
#_____________________________________________
evaluate_retval
fi
done
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
# End /etc/init.d/ethnet