#!/bin/sh
# Begin $network-devices/services/dhcpcd
                                                                                
# Based upon lfs-bootscripts-1.12 $network_devices/if{down,up}
# Rewritten by Nathan Coulson <nathan@linuxfromscratch.org>
# Adapted for dhcpcd by DJ Lucas <dj@lucasit.com>

. /etc/sysconfig/rc
. $rc_functions
. $network_devices/ifconfig.$1
                                                                                
case "$2" in
        up)
                echo "Bringing up the $1 interface (dhcpcd)..."
                # Test to see if there is a stale pid file
                if [ -f /var/run/dhcpcd-$1.pid ]
                then
                    ps $(cat /var/run/dhcpcd-$1.pid) | grep dhcpcd > /dev/null
                    if [ $? != 0 ]
                    then
                        rm -f /var/run/dhcpcd-$1.pid > /dev/null
                    else
                        print_status warning running
                        exit 2
                    fi
                fi
                /sbin/dhcpcd $1 $DHCP_START
                evaluate_retval
        ;;
                                                                                
        down)
                echo "Bringing down the $1 interface (dhcpcd)..."
                /sbin/dhcpcd $1 $DHCP_STOP
                evaluate_retval
        ;;
                                                                                
        *)
                echo "Usage: $0 [interface] {up|down}"
                exit 1
        ;;
esac
                                                                                
# End $network_devices/services/dhcpcd
