1 | #!/bin/bash
|
---|
2 | # Begin services/dhcpcd
|
---|
3 |
|
---|
4 | # Origianlly dased 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@linuxfromscratch.org>
|
---|
7 | # Update for LFS 7.0 by Bruce Dubbs <bdubbs@linuxfromscratch,org>
|
---|
8 |
|
---|
9 | # Call with: IFCONFIG=<filename> /lib/services/dhcpcd <IFACE> <up | down>
|
---|
10 |
|
---|
11 | #$LastChangedBy: bdubbs $
|
---|
12 | #$Date: 2012-04-09 21:48:51 +0200 (Mon, 09 Apr 2012) $
|
---|
13 |
|
---|
14 | . /lib/lsb/init-functions
|
---|
15 | . $IFCONFIG
|
---|
16 |
|
---|
17 | pidfile="/var/run/dhcpcd-$1.pid"
|
---|
18 |
|
---|
19 | case "$2" in
|
---|
20 | up)
|
---|
21 | # Cosmetic output not needed for multiple services
|
---|
22 | if ! $(echo ${SERVICE} | grep -q " "); then
|
---|
23 | log_info_msg2 "\n" # Terminate the previous message
|
---|
24 | fi
|
---|
25 |
|
---|
26 | log_info_msg "Starting dhcpcd on the $1 interface..."
|
---|
27 |
|
---|
28 | # Test to see if there is a stale pid file
|
---|
29 | if [ -f "$pidfile" ]; then
|
---|
30 | ps `cat "$pidfile"` | grep dhcpcd > /dev/null
|
---|
31 |
|
---|
32 | if [ $? != 0 ]; then
|
---|
33 | rm -f /var/run/dhcpcd-$1.pid > /dev/null
|
---|
34 |
|
---|
35 | else
|
---|
36 | log_warning_msg "dhcpcd is already running!"
|
---|
37 | exit 2
|
---|
38 | fi
|
---|
39 | fi
|
---|
40 |
|
---|
41 | /sbin/dhcpcd $1 $DHCP_START
|
---|
42 | evaluate_retval
|
---|
43 | ;;
|
---|
44 |
|
---|
45 | down)
|
---|
46 | log_info_msg "Stopping dhcpcd on the $1 interface..."
|
---|
47 |
|
---|
48 | if [ -z "$DHCP_STOP" ]; then
|
---|
49 | killproc -p "${pidfile}" /sbin/dhcpcd
|
---|
50 |
|
---|
51 | else
|
---|
52 | /sbin/dhcpcd $1 $DHCP_STOP &> /dev/null
|
---|
53 |
|
---|
54 | if [ "$?" -eq 1 ]; then
|
---|
55 | log_warning_msg "dhcpcd not running!"
|
---|
56 | exit 2
|
---|
57 | fi
|
---|
58 | fi
|
---|
59 |
|
---|
60 | evaluate_retval
|
---|
61 | ;;
|
---|
62 |
|
---|
63 | *)
|
---|
64 | echo "Usage: $0 [interface] {up|down}"
|
---|
65 | exit 1
|
---|
66 | ;;
|
---|
67 | esac
|
---|
68 |
|
---|
69 | # End services/dhcpcd
|
---|