]> git.pld-linux.org Git - packages/xen.git/blob - xen-xend.init
- subpackage for hypervisor
[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 condrestart() {
53         if [ -f /var/lock/subsys/xend ]; then
54                 stop
55                 start
56         else
57             msg_not_running Xend
58                 RETVAL=$1
59         fi
60 }
61
62 RETVAL=0
63 case "$1" in
64   start)
65         start
66         ;;
67   stop)
68         stop
69         ;;
70   restart)
71         stop
72         start
73         ;;
74   try-restart)
75         condrestart 0
76         ;;
77   force-reload)
78         condrestart 7
79         ;;
80   status)
81         /usr/sbin/xend status
82         ;;
83   *)
84         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
85         exit 3
86 esac
87
88 exit $RETVAL
This page took 0.043042 seconds and 3 git commands to generate.