aboutsummaryrefslogtreecommitdiffstats
path: root/testing/xen/xendomains.initd
diff options
context:
space:
mode:
Diffstat (limited to 'testing/xen/xendomains.initd')
-rw-r--r--testing/xen/xendomains.initd63
1 files changed, 63 insertions, 0 deletions
diff --git a/testing/xen/xendomains.initd b/testing/xen/xendomains.initd
new file mode 100644
index 0000000000..d12577c2b0
--- /dev/null
+++ b/testing/xen/xendomains.initd
@@ -0,0 +1,63 @@
+#!/sbin/runscript
+
+depend() {
+ need xend
+ after dhcp
+}
+
+get_domname() {
+ local name_from_file=$(sed -rn 's/^name\W*=\W*\"?([[:alnum:]_\.-]+)\"?\W*;?/\1/p' "${1}" | tail -n 1)
+
+ if [[ -z ${name_from_file} ]] ; then
+ basename "${1}"
+ else
+ echo ${name_from_file}
+ fi
+}
+
+is_running() {
+ /usr/sbin/xm list "${1}" >/dev/null 2>&1
+}
+
+start() {
+ einfo "Starting Xen domains in ${AUTODIR:=/etc/xen/auto}"
+
+ for dom in $(ls "${AUTODIR:=/etc/xen/auto}/"* 2>/dev/null | sort); do
+ name=$(get_domname ${dom})
+ if ! is_running ${name} ; then
+ ebegin " Starting domain ${name}"
+ xm create --quiet ${dom}
+ eend $?
+ else
+ einfo " Not starting ${name} - already running."
+ fi
+ done
+}
+
+stop() {
+ einfo "Stopping Xen domains in ${AUTODIR:=/etc/xen/auto}"
+
+ for dom in $(ls "${AUTODIR:=/etc/xen/auto}/"* 2>/dev/null | sort); do
+ name=$(get_domname ${dom})
+ if is_running ${name} ; then
+ ebegin " Sending shutdown signal to ${name}"
+ xm shutdown ${name} >/dev/null
+ eend $?
+ fi
+ done
+
+ for dom in $(ls "${AUTODIR:=/etc/xen/auto}/"* 2>/dev/null | sort); do
+ name=$(get_domname ${dom})
+ if is_running ${name} ; then
+ ebegin " Waiting for domain ${name} to shutdown"
+ xm shutdown --wait ${name}
+ eend $?
+ else
+ einfo " Not stopping ${name} - not running."
+ fi
+ done
+}
+
+status() {
+ /usr/sbin/xm list
+}