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