summaryrefslogtreecommitdiff
blob: afc796c9367a90aad877846ddc87c48c74b96d63 (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
61
62
63
64
65
66
67
#!/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.3 2005/10/08 12:32:33 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} Xen domains"
	if [[ ${SCREEN} == "yes" ]]; then
		screen -d -m -S xen -t xen-cbc0
		screen -r xen -X zombie dr
		logrotate -f /usr/share/xen/xen-consoles-logrotate
		screen -r xen -X logfile /var/log/xen-consoles/%t
		screen -r xen -X logfile flush 1
		screen -r xen -X deflog on
	fi
	# 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}"
			if [[ ${SCREEN} == "yes" ]]; then
				screen -r xen -X screen -t ${name} xm create ${dom} -c
			else
				xm create --quiet ${dom}
			fi
			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}"
				xm shutdown --wait ${name} >/dev/null
			eend $?
		else
			einfo "  Not Stopping domain ${name} - not running"
		fi
	done
	if [[ ${SCREEN} == "yes" ]]; then
		screen -r xen -X quit
	fi
}

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