summaryrefslogtreecommitdiffstats
path: root/main/xe-guest-utilities/xe-guest-utilities.initd
blob: 2d9c880da7a758992592e950e42192d84d12dea3 (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
#!/sbin/runscript

XE_LINUX_DISTRIBUTION=/usr/sbin/xe-linux-distribution
XE_LINUX_DISTRIBUTION_CACHE=/var/cache/xe-linux-distribution
XE_DAEMON=/usr/sbin/xe-daemon
XE_DAEMON_PIDFILE=/var/run/xe-daemon.pid

name=xe-daemon
daemon=/usr/sbin/$name

depend() {
	need localmount
	after bootmisc
}

start() {
	if [ ! -d /proc/xen ]; then
		return
	fi

	ebegin "Detecting Linux distribution version"
		${XE_LINUX_DISTRIBUTION} ${XE_LINUX_DISTRIBUTION_CACHE}
	eend $?

	if [ ! -e /proc/xen/xenbus ] ; then
		ebegin "Mounting xenfs on /proc/xen"
			if [ ! -d /proc/xen ] ; then
				/bin/false
			else
				mount -t xenfs none /proc/xen
			fi
		eend $?
	fi

	ebegin "Starting ${name}"
		mkdir -p $(dirname ${XE_DAEMON_PIDFILE})
		( exec &>/dev/null ; ${XE_DAEMON} -p ${XE_DAEMON_PIDFILE} & )
	eend $?
}

stop() {
	if [ ! -d /proc/xen ]; then
		return
	fi

	ebegin "Stopping ${name}"
		kill -TERM $(cat ${XE_DAEMON_PIDFILE})
	eend $?
}