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