]> git.pld-linux.org Git - packages/dhcdbd.git/blame - dhcdbd.init
- always remove lockfile. otherwise it's impossible to start daemon if stop fails...
[packages/dhcdbd.git] / dhcdbd.init
CommitLineData
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.
25if 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
30else
31 exit 0
32fi
33
7c37a40f 34start() {
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
49stop() {
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
628b2201
ER
70 ok
71 else
72 fail
ac62f9bc 73 fi
628b2201 74 rm -f /var/lock/subsys/dhcdbd /var/run/dhcdbd.pid >/dev/null 2>&1
ac62f9bc 75 else
76 msg_not_running dhcdbd
77 fi
78 else
79 msg_not_running messagebus
80 fi
7c37a40f
ER
81}
82
519ed882
ER
83condrestart() {
84 if [ -f /var/lock/subsys/dhcdbd ]; then
85 stop
86 start
87 else
88 msg_not_running dhcdbd
89 RETVAL=$1
90 fi
91}
92
7c37a40f
ER
93RETVAL=0
94# See how we were called.
95case "$1" in
96 start)
97 start
98 ;;
99 stop)
100 stop
101 ;;
102 restart)
103 stop
104 start
ac62f9bc 105 ;;
519ed882
ER
106 try-restart)
107 condrestart 0
108 ;;
109 force-reload)
110 condrestart 7
111 ;;
ac62f9bc 112 status)
113 status dhcdbd
114 if [ $? -eq 0 ]; then
115 pid=`cat /var/run/dhcdbd.pid`
116 if [ $? -eq 0 -a -n "$pid" ]; then
117 sender=`/usr/bin/dbus-send \
118 --system \
119 --dest=com.redhat.dhcp \
120 --type=method_call \
121 --print-reply \
122 --reply-timeout=20000 \
123 /com/redhat/dhcp \
124 com.redhat.dhcp.ping |
125 grep 'sender=' | sed 's/^.*sender=//;s/\ .*$//'`
126 if [ $? -eq 0 ]; then
127 echo 'it is listening on '$sender
128 fi
129 fi
130 fi
131 ;;
ac62f9bc 132 *)
519ed882 133 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
ac62f9bc 134 exit 3
135 ;;
136esac
137
138exit $RETVAL
This page took 0.098821 seconds and 4 git commands to generate.