]>
Commit | Line | Data |
---|---|---|
ac62f9bc | 1 | #!/bin/sh |
2 | # | |
3 | # dhcdbd DHCP Client D-BUS Daemon | |
4 | # | |
5 | # chkconfig: 345 89 11 | |
6 | # description: dhcdbd provides D-BUS control of the ISC DHCP client, dhclient, | |
3930790e | 7 | # and D-BUS access to the DHCP options obtained by dhclient |
ac62f9bc | 8 | # for each IPv4 interface. |
9 | # processname: dhcdbd | |
10 | # pidfile: /var/run/dhcdbd.pid | |
11 | # config: /etc/dbus-1/system.d/dhcdbd.conf | |
7c37a40f ER |
12 | # |
13 | # $Id$ | |
ac62f9bc | 14 | |
15 | # Source function library | |
16 | . /etc/rc.d/init.d/functions | |
17 | ||
18 | # Get network config | |
19 | . /etc/sysconfig/network | |
20 | ||
21 | # Get service config | |
22 | [ -f /etc/sysconfig/dhcdbd ] && . /etc/sysconfig/dhcdbd | |
23 | ||
24 | # Check that networking is up. | |
25 | if is_yes "${NETWORKING}"; then | |
26 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
ac62f9bc | 27 | msg_network_down dhcdbd |
28 | exit 1 | |
29 | fi | |
30 | else | |
31 | exit 0 | |
32 | fi | |
33 | ||
7c37a40f | 34 | start() { |
ac62f9bc | 35 | if [ -f /var/lock/subsys/messagebus ]; then |
36 | if [ ! -f /var/lock/subsys/dhcdbd ]; then | |
37 | msg_starting dhcdbd | |
720b7239 | 38 | daemon /usr/sbin/dhcdbd --system |
ac62f9bc | 39 | RETVAL=$? |
40 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcdbd | |
41 | else | |
42 | msg_already_running dhcdbd | |
43 | fi | |
44 | else | |
45 | msg_not_running messagebus | |
46 | fi | |
7c37a40f ER |
47 | } |
48 | ||
49 | stop() { | |
ac62f9bc | 50 | msg_stopping dhcdbd |
51 | if [ -f /var/run/dhcdbd.pid ]; then | |
52 | checkpid `cat /var/run/dhcdbd.pid` >/dev/null 2>&1 | |
53 | if [ $? -eq 1 ]; then | |
54 | rm -f /var/lock/subsys/dhcdbd /var/run/dhcdbd.pid >/dev/null 2>&1 | |
55 | died | |
56 | exit 0 | |
57 | fi | |
58 | fi | |
59 | if [ -f /var/lock/subsys/messagebus ]; then | |
60 | if [ -f /var/lock/subsys/dhcdbd ]; then | |
61 | /usr/bin/dbus-send \ | |
62 | --system \ | |
63 | --dest=com.redhat.dhcp \ | |
64 | --type=method_call \ | |
65 | --print-reply \ | |
66 | --reply-timeout=20000 \ | |
67 | /com/redhat/dhcp \ | |
68 | com.redhat.dhcp.quit >/dev/null 2>&1 | |
69 | if [ $? -eq 0 ]; then | |
70 | rm -f /var/lock/subsys/dhcdbd /var/run/dhcdbd.pid >/dev/null 2>&1 | |
71 | fi | |
72 | ok | |
73 | else | |
74 | msg_not_running dhcdbd | |
75 | fi | |
76 | else | |
77 | msg_not_running messagebus | |
78 | fi | |
7c37a40f ER |
79 | } |
80 | ||
81 | RETVAL=0 | |
82 | # See how we were called. | |
83 | case "$1" in | |
84 | start) | |
85 | start | |
86 | ;; | |
87 | stop) | |
88 | stop | |
89 | ;; | |
90 | restart) | |
91 | stop | |
92 | start | |
ac62f9bc | 93 | ;; |
94 | status) | |
95 | status dhcdbd | |
96 | if [ $? -eq 0 ]; then | |
97 | pid=`cat /var/run/dhcdbd.pid` | |
98 | if [ $? -eq 0 -a -n "$pid" ]; then | |
99 | sender=`/usr/bin/dbus-send \ | |
100 | --system \ | |
101 | --dest=com.redhat.dhcp \ | |
102 | --type=method_call \ | |
103 | --print-reply \ | |
104 | --reply-timeout=20000 \ | |
105 | /com/redhat/dhcp \ | |
106 | com.redhat.dhcp.ping | | |
107 | grep 'sender=' | sed 's/^.*sender=//;s/\ .*$//'` | |
108 | if [ $? -eq 0 ]; then | |
109 | echo 'it is listening on '$sender | |
110 | fi | |
111 | fi | |
112 | fi | |
113 | ;; | |
ac62f9bc | 114 | *) |
115 | msg_usage "$0 {start|stop|restart|status}" | |
116 | exit 3 | |
117 | ;; | |
118 | esac | |
119 | ||
120 | exit $RETVAL |