]> git.pld-linux.org Git - packages/xen.git/blob - xen-xend.init
- use functions
[packages/xen.git] / xen-xend.init
1 #!/bin/sh
2 #
3 # xend          Script to start and stop the Xen control daemon.
4 #
5 # Author:       Keir Fraser <keir.fraser@cl.cam.ac.uk>
6 #
7 # chkconfig: 2345 98 01
8 # description: Starts and stops the Xen control daemon.
9
10 # Source function library
11 . /etc/rc.d/init.d/functions
12
13 if ! [ -e /proc/xen/privcmd ]; then
14         exit 0
15 fi
16
17 await_daemons_up()
18 {
19         retval=$1
20         i=1
21         rets=10
22         /usr/sbin/xend status
23         while [ $? -ne 0 -a $i -lt $rets ]; do
24             sleep 1
25             i=$(($i + 1))
26             /usr/sbin/xend status > /dev/null 2>&1
27         done
28 }
29
30 start() {
31         if [ ! -f /var/lock/subsys/xend ]; then
32                 msg_starting "xend"
33                 daemon /usr/sbin/xend start
34             RETVAL=$?
35                 await_daemons_up
36             [ $RETVAL -eq 0 ] && touch /var/lock/subsys/xend
37         else
38             msg_already_running xend
39         fi
40 }
41
42 stop() {
43         if [ -f /var/lock/subsys/xend ]; then
44             msg_stopping "xend"
45                 daemon /usr/sbin/xend stop
46             rm -f /var/lock/subsys/xend >/dev/null 2>&1
47         else
48             msg_not_running "xend"
49         fi
50 }
51
52 RETVAL=0
53 case "$1" in
54   start)
55         start
56         ;;
57   stop)
58         stop
59         ;;
60   restart|force-reload)
61         stop
62         start
63         ;;
64   status)
65         /usr/sbin/xend status
66         ;;
67   *)
68         echo $"Usage: $0 {start|stop|status|restart|force-reload}"
69         exit 3
70 esac
71
72 exit $RETVAL
This page took 0.041455 seconds and 3 git commands to generate.