[7125722] | 1 | #!/bin/sh
|
---|
| 2 | # Begin $network-devices/services/dhcpcd
|
---|
| 3 |
|
---|
| 4 | # Based upon lfs-bootscripts-1.12 $network_devices/if{down,up}
|
---|
| 5 | # Rewritten by Nathan Coulson <nathan@linuxfromscratch.org>
|
---|
| 6 | # Adapted for dhcpcd by DJ Lucas <dj@lucasit.com>
|
---|
| 7 |
|
---|
[1d02f01] | 8 | #$LastChangedBy$
|
---|
| 9 | #$Date$
|
---|
[7125722] | 10 |
|
---|
| 11 | . /etc/sysconfig/rc
|
---|
| 12 | . $rc_functions
|
---|
| 13 | . $IFCONFIG
|
---|
| 14 |
|
---|
[1d02f01] | 15 | pidfile="/var/run/dhcpcd-$1.pid"
|
---|
| 16 | leaseinfo="/var/lib/dhcpcd/dhcpcd-$1.info"
|
---|
[7125722] | 17 |
|
---|
| 18 | case "$2" in
|
---|
| 19 | up)
|
---|
| 20 | boot_mesg -n "Starting dhcpcd on the $1 interface..."
|
---|
| 21 | # Test to see if there is a stale pid file
|
---|
[1d02f01] | 22 | if [ -f "$pidfile" ]; then
|
---|
| 23 | ps `cat "$pidfile"` | grep dhcpcd > /dev/null
|
---|
| 24 | if [ $? != 0 ]; then
|
---|
| 25 | rm -f $pidfile > /dev/null
|
---|
[7125722] | 26 | else
|
---|
| 27 | boot_mesg "dhcpcd already running!" ${WARNING}
|
---|
| 28 | echo_warning
|
---|
| 29 | exit 2
|
---|
| 30 | fi
|
---|
| 31 | fi
|
---|
| 32 | /sbin/dhcpcd $1 $DHCP_START
|
---|
| 33 | # Save the return value
|
---|
| 34 | RET="$?"
|
---|
| 35 | # Print the assigned settings if requested
|
---|
| 36 | if [ "$RET" = "0" -a "$PRINTIP" = "yes" ]; then
|
---|
[1d02f01] | 37 | . $leaseinfo
|
---|
[7125722] | 38 | if [ "$PRINTALL" = "yes" ]; then
|
---|
| 39 | echo ""
|
---|
| 40 | echo_ok
|
---|
| 41 | boot_mesg " DHCP Assigned Settings for $1:"
|
---|
| 42 | boot_mesg_flush
|
---|
| 43 | boot_mesg " IP Address: $IPADDR"
|
---|
| 44 | boot_mesg_flush
|
---|
| 45 | boot_mesg " Subnet Mask: $NETMASK"
|
---|
| 46 | boot_mesg_flush
|
---|
| 47 | boot_mesg " Default Gateway: $GATEWAYS"
|
---|
| 48 | boot_mesg_flush
|
---|
| 49 | boot_mesg " DNS Server: $DNSSERVERS"
|
---|
| 50 | boot_mesg_flush
|
---|
| 51 | else
|
---|
| 52 | boot_mesg " IP Addresss: $IPADDR"
|
---|
| 53 | echo_ok
|
---|
| 54 | fi
|
---|
| 55 | else
|
---|
| 56 | echo ""
|
---|
| 57 | $(exit "$RET")
|
---|
| 58 | evaluate_retval
|
---|
| 59 | fi
|
---|
| 60 | ;;
|
---|
| 61 |
|
---|
| 62 | down)
|
---|
| 63 | boot_mesg -n "Stopping dhcpcd on the $1 interface..."
|
---|
[1d02f01] | 64 | if [ -z "$DHCP_STOP" ]; then
|
---|
[7125722] | 65 | echo ""
|
---|
[1d02f01] | 66 | killproc -p "$pidfile" /sbin/dhcpcd
|
---|
[7125722] | 67 | else
|
---|
| 68 | /sbin/dhcpcd $1 $DHCP_STOP &> /dev/null
|
---|
| 69 | RET="$?"
|
---|
| 70 | if [ "$RET" -eq 0 ]; then
|
---|
| 71 | echo ""
|
---|
| 72 | echo_ok
|
---|
| 73 | elif [ "$RET" -eq 1 ]; then
|
---|
| 74 | boot_mesg "dhcpcd not running!" ${WARNING}
|
---|
| 75 | echo_warning
|
---|
| 76 | else
|
---|
| 77 | echo ""
|
---|
| 78 | echo_failure
|
---|
| 79 | fi
|
---|
| 80 | fi
|
---|
| 81 | ;;
|
---|
| 82 |
|
---|
| 83 | *)
|
---|
| 84 | echo "Usage: $0 [interface] {up|down}"
|
---|
| 85 | exit 1
|
---|
| 86 | ;;
|
---|
| 87 | esac
|
---|
| 88 |
|
---|
| 89 | # End $network_devices/services/dhcpcd
|
---|
[1d02f01] | 90 |
|
---|