summaryrefslogtreecommitdiff
blob: f9bdeb3474ad17652e4468c1ab9d15f9ccc939d3 (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
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-emulation/xen/files/xendomains-init,v 1.2 2005/09/20 08:57:06 chrb Exp $

opts="start stop status restart"

depend() {
	need xend
}

get_domname() {
	sed -ne 's/^[ \t]*name[ \t]*=[ \t]*"\([^"]*\)"/\1/p' $1
}

is_running() {
	[ -n "`/usr/sbin/xm list | grep "^${1} "`" ]
}

start() {
	einfo "Starting ${AUTODIR} auto Xen domains"
	# Create all domains with config files in AUTODIR.
	for dom in $(ls ${AUTODIR}/* 2>/dev/null); do
		name=$(get_domname ${dom})
		if ! is_running ${name} ; then
			ebegin "  Starting domain ${name}"
			/usr/sbin/xm create --quiet --defconfig ${dom}
			eend $?
		else
			einfo "  Not Starting domain ${name} - allready running"
		fi
	done
}

stop() {
	einfo "Shutting down ${AUTODIR} Xen domains"
	# Stop all domains with config files in AUTODIR.
	for dom in $(ls ${AUTODIR}/* 2>/dev/null); do
		name=$(get_domname ${dom})
		if is_running ${name} ; then
			ebegin "  Stopping domain ${name}"
			/usr/sbin/xm shutdown --halt --wait ${name} >/dev/null
			eend $?
		else
			einfo "  Not Stopping domain ${name} - not running"
		fi
	done
}

status() {
	/usr/sbin/xm list
}