aboutsummaryrefslogtreecommitdiffstats
path: root/main/xen/xendomains.initd
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2011-02-17 19:06:17 -0600
committerWilliam Pitcock <nenolod@dereferenced.org>2011-02-17 19:06:17 -0600
commitbd4729f70cc9cd71d9defca1cd0dc82893bf8f10 (patch)
tree0c39c7f0f0dc3e39f1d6a5701b4256d56db51235 /main/xen/xendomains.initd
parentf369602f6bfd7345808a67c2427e770e97f44ca5 (diff)
downloadaports-bd4729f70cc9cd71d9defca1cd0dc82893bf8f10.tar.bz2
aports-bd4729f70cc9cd71d9defca1cd0dc82893bf8f10.tar.xz
testing/xen: promote to main
Diffstat (limited to 'main/xen/xendomains.initd')
-rw-r--r--main/xen/xendomains.initd63
1 files changed, 63 insertions, 0 deletions
diff --git a/main/xen/xendomains.initd b/main/xen/xendomains.initd
new file mode 100644
index 0000000000..d12577c2b0
--- /dev/null
+++ b/main/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
+}