aboutsummaryrefslogtreecommitdiffstats
path: root/main/xen/xendomains.initd
diff options
context:
space:
mode:
authorRoger Pau Monne <roger.pau@entel.upc.edu>2012-02-22 00:19:13 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2012-03-08 18:20:25 +0000
commit87b35cc3a59287e2c1c540c6e263454992a27216 (patch)
treef757b5d7858e677ac4894a5afe376f2398bec21b /main/xen/xendomains.initd
parentea858919b459042138958b7b669816a84026546a (diff)
downloadaports-87b35cc3a59287e2c1c540c6e263454992a27216.tar.bz2
aports-87b35cc3a59287e2c1c540c6e263454992a27216.tar.xz
main/xen: fix xendomains init script
Diffstat (limited to 'main/xen/xendomains.initd')
-rwxr-xr-x[-rw-r--r--]main/xen/xendomains.initd59
1 files changed, 34 insertions, 25 deletions
diff --git a/main/xen/xendomains.initd b/main/xen/xendomains.initd
index 0f309ef3d0..5077d82e03 100644..100755
--- a/main/xen/xendomains.initd
+++ b/main/xen/xendomains.initd
@@ -1,26 +1,5 @@
#!/sbin/runscript
-CMD=xm
-/usr/sbin/$CMD list &> /dev/null
-if test $? -ne 0
-then
- CMD=xl
-fi
-
-/usr/sbin/$CMD list &> /dev/null
-if test $? -ne 0
-then
- eend 1;
- exit 1;
-fi
-
-# Correct exit code would probably be 5, but it's enough
-# if xend complains if we're not running as privileged domain
-if ! [ -e /proc/xen/privcmd ]; then
- eend 1;
- exit 1;
-fi
-
# See docs/misc/distro_mapping.txt
if [ -d /var/lock/subsys ]; then
LOCKFILE=/var/lock/subsys/xendomains
@@ -37,7 +16,7 @@ fi
if ! [ -r $XENDOM_CONFIG ]; then
eend 1;
echo "$XENDOM_CONFIG not existing";
- exit 1;
+ return 1;
fi
. $XENDOM_CONFIG
@@ -61,14 +40,41 @@ is_running() {
/usr/sbin/$CMD list "${1}" >/dev/null 2>&1
}
+check_xen() {
+ CMD=xm
+ /usr/sbin/$CMD list &> /dev/null
+ if test $? -ne 0
+ then
+ CMD=xl
+ fi
+
+ /usr/sbin/$CMD list &> /dev/null
+ if test $? -ne 0
+ then
+ eend 1;
+ echo "Could not find xl or xm";
+ return 1;
+ fi
+
+ # Correct exit code would probably be 5, but it's enough
+ # if xend complains if we're not running as privileged domain
+ if ! [ -e /proc/xen/privcmd ]; then
+ eend 1;
+ echo "Could not find /proc/xen/privcmd";
+ return 1;
+ fi
+}
+
start() {
einfo "Starting Xen domains in ${AUTODIR:=/etc/xen/auto}"
+ check_xen
+
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}"
- /usr/sbin/$CMD create --quiet --defconfig ${dom}
+ /usr/sbin/$CMD create --quiet --defconfig ${dom} >/dev/null 2>&1
eend $?
else
einfo " Not starting ${name} - already running."
@@ -79,11 +85,13 @@ start() {
stop() {
einfo "Stopping Xen domains in ${AUTODIR:=/etc/xen/auto}"
+ check_xen
+
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}"
- /usr/sbin/$CMD shutdown ${name} >/dev/null
+ /usr/sbin/$CMD shutdown ${name} >/dev/null 2>&1
eend $?
fi
done
@@ -92,7 +100,7 @@ stop() {
name=$(get_domname ${dom})
if is_running ${name} ; then
ebegin " Waiting for domain ${name} to shutdown"
- /usr/sbin/$CMD shutdown --wait ${name}
+ /usr/sbin/$CMD shutdown --wait ${name} >/dev/null 2>&1
eend $?
else
einfo " Not stopping ${name} - not running."
@@ -101,5 +109,6 @@ stop() {
}
status() {
+ check_xen
/usr/sbin/$CMD list
}