]> git.pld-linux.org Git - packages/xen.git/blob - xenstored.init
xenstored must not be ever stopped
[packages/xen.git] / xenstored.init
1 #!/bin/sh
2 #
3 # xenstored     Script to start and stop xenstored
4 #
5 # chkconfig:    2345 69 31
6 # description:  Starts and stops xenstored
7 #
8
9 # Source function library
10 . /etc/rc.d/init.d/functions
11
12 # Read in configuration options.
13 [ -f /etc/sysconfig/xenstored ] && . /etc/sysconfig/xenstored
14
15 if [ "$1" = "start" -a -d /proc/xen -a ! -f /proc/xen/capabilities ] && \
16                 ! grep -qs '^xenfs ' /proc/mounts >/dev/null; then
17         mount -t xenfs xenfs /proc/xen
18 fi
19
20 grep -qs "control_d" /proc/xen/capabilities || exit 0
21
22 start () {
23         if [ -f /var/lock/subsys/xenstored ]; then
24                 msg_already_running xenstored
25                 return
26         fi
27         xenstore-read -s / >/dev/null 2>/dev/null && return
28
29         [ -z "$XENSTORED_ROOTDIR" ] || XENSTORED_ROOTDIR="/var/lib/xenstored"
30         rm -f "$XENSTORED_ROOTDIR"/tdb* >/dev/null 2>/dev/null
31
32         show "Starting xenstored"
33         busy
34         /usr/sbin/xenstored --pid-file=/var/run/xenstored.pid $XENSTORED_ARGS
35
36         # Wait for xenstored to actually come up, timing out after 30 seconds
37         time=0
38         timeout=30
39         while [ $time -lt $timeout ] && ! xenstore-read -s / >/dev/null 2>/dev/null ; do
40             time=$(($time+1))
41             sleep 1
42         done
43
44         if [ $time -ge $timeout ]; then
45                 fail
46                 RETVAL=1
47                 return
48         fi
49         ok
50
51         show "Setting domain 0 name"
52         busy
53         xenstore-write "/local/domain/0/name" "Domain-0"
54         ok
55         touch /var/lock/subsys/xenstored
56 }
57
58 stop() {
59         if [ -f /var/lock/subsys/xenstored ]; then
60                 echo WARNING: Not stopping xenstored, as it cannot be restarted.
61         fi
62 }
63
64 RETVAL=0
65 # See how we were called.
66 case "$1" in
67   start)
68         start
69         ;;
70   status)
71         status xenstored
72         xenstore-read -s /
73         ;;
74   stop)
75         stop
76         ;;
77   force-reload|restart)
78         stop
79         start
80         ;;
81   *)
82         msg_usage "$0 {start|stop|status|restart|force-reload}"
83         exit 3
84 esac
85
86 exit $RETVAL
This page took 0.060189 seconds and 3 git commands to generate.