summaryrefslogtreecommitdiffstats
path: root/main/xen/xenstored.initd
blob: f2c22cc705f1c8a4a0441d3079333571fc2f3461 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-emulation/xen-tools/files/xenstored.initd,v 1.2 2011/04/05 21:25:03 alexxy Exp $

depend() {
	need net
	before xendomains xend sshd ntp-client ntpd nfs nfsmount rsyncd portmap dhcp 
}

wait_xenstored_up() {
	local time=0 timeout=30
	while ! xenstore-read -s / >/dev/null 2>&1; do
		time=$(($time+1))
		if [ $time -gt $timeout ]; then
			return 1
		fi
		sleep 1
	done
	return 0
}

start() {
	local _traceopt=
	ebegin "Starting xenstored daemon"

	if ! test -f /proc/xen/capabilities && \
	   ! grep '^xenfs ' /proc/mounts >/dev/null;
	then
		mount -t xenfs xenfs /proc/xen
	fi

	modprobe xen-evtchn 2>/dev/null
	modprobe xen-gntdev 2>/dev/null
	modprobe evtchn 2>/dev/null
	modprobe gntdev 2>/dev/null

	if yesno "$XENSTORED_TRACE"; then
		_traceopt="-T /var/log/xen/xenstored-trace.log"
	fi

	start-stop-daemon --start --exec /usr/sbin/xenstored \
		--pidfile /var/run/xenstored.pid \
		-- --pid-file=/var/run/xenstored.pid \
		$XENSTORED_OPTS $_traceopt
	wait_xenstored_up
	eend $? || return 1

	einfo "Setting domain0 name record"
	/usr/bin/xenstore-write "/local/domain/0/name" "Domain-0"
	eend $*
}

stop() {
	ebegin "Stopping xenstored daemon"
	start-stop-daemon --stop --exec /usr/sbin/xenstored \
		--pidfile /var/run/xenstored.pid
	eend $?
}