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 |
|
---|
8 | #$LastChangedBy: dj $
|
---|
9 | #$Date: 2007-08-21 23:09:21 -0500 (Tue, 21 Aug 2007) $
|
---|
10 |
|
---|
11 | . /etc/sysconfig/rc
|
---|
12 | . $rc_functions
|
---|
13 | . $IFCONFIG
|
---|
14 |
|
---|
15 | PIDFILE="/var/run/dhcpcd-$1.pid"
|
---|
16 | LEASEINFO="/var/lib/dhcpcd/dhcpcd-$1.info"
|
---|
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
|
---|
22 | if [ -f "$PIDFILE" ]
|
---|
23 | then
|
---|
24 | ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null
|
---|
25 | if [ $? != 0 ]
|
---|
26 | then
|
---|
27 | rm -f $PIDFILE > /dev/null
|
---|
28 | else
|
---|
29 | boot_mesg "dhcpcd already running!" ${WARNING}
|
---|
30 | echo_warning
|
---|
31 | exit 2
|
---|
32 | fi
|
---|
33 | fi
|
---|
34 | /sbin/dhcpcd $1 $DHCP_START
|
---|
35 | # Save the return value
|
---|
36 | RET="$?"
|
---|
37 | # Print the assigned settings if requested
|
---|
38 | if [ "$RET" = "0" -a "$PRINTIP" = "yes" ]; then
|
---|
39 | . $LEASEINFO
|
---|
40 | if [ "$PRINTALL" = "yes" ]; then
|
---|
41 | echo ""
|
---|
42 | echo_ok
|
---|
43 | boot_mesg " DHCP Assigned Settings for $1:"
|
---|
44 | boot_mesg_flush
|
---|
45 | boot_mesg " IP Address: $IPADDR"
|
---|
46 | boot_mesg_flush
|
---|
47 | boot_mesg " Subnet Mask: $NETMASK"
|
---|
48 | boot_mesg_flush
|
---|
49 | boot_mesg " Default Gateway: $GATEWAYS"
|
---|
50 | boot_mesg_flush
|
---|
51 | boot_mesg " DNS Server: $DNSSERVERS"
|
---|
52 | boot_mesg_flush
|
---|
53 | else
|
---|
54 | boot_mesg " IP Addresss: $IPADDR"
|
---|
55 | echo_ok
|
---|
56 | fi
|
---|
57 | else
|
---|
58 | echo ""
|
---|
59 | $(exit "$RET")
|
---|
60 | evaluate_retval
|
---|
61 | fi
|
---|
62 | ;;
|
---|
63 |
|
---|
64 | down)
|
---|
65 | boot_mesg -n "Stopping dhcpcd on the $1 interface..."
|
---|
66 | if [ -z "$DHCP_STOP" ]
|
---|
67 | then
|
---|
68 | echo ""
|
---|
69 | killproc -p "$PIDFILE" /sbin/dhcpcd
|
---|
70 | else
|
---|
71 | /sbin/dhcpcd $1 $DHCP_STOP &> /dev/null
|
---|
72 | RET="$?"
|
---|
73 | if [ "$RET" -eq 0 ]; then
|
---|
74 | echo ""
|
---|
75 | echo_ok
|
---|
76 | elif [ "$RET" -eq 1 ]; then
|
---|
77 | boot_mesg "dhcpcd not running!" ${WARNING}
|
---|
78 | echo_warning
|
---|
79 | else
|
---|
80 | echo ""
|
---|
81 | echo_failure
|
---|
82 | fi
|
---|
83 | fi
|
---|
84 | ;;
|
---|
85 |
|
---|
86 | *)
|
---|
87 | echo "Usage: $0 [interface] {up|down}"
|
---|
88 | exit 1
|
---|
89 | ;;
|
---|
90 | esac
|
---|
91 |
|
---|
92 | # End $network_devices/services/dhcpcd
|
---|