Mail archive
alpine-devel

[alpine-devel] [PATCH] main/xen: fix xendomains init script

From: Roger Pau Monne <roger.pau_at_entel.upc.edu>
Date: Tue, 21 Feb 2012 23:43:08 +0100

---
 main/xen/APKBUILD         |    4 +-
 main/xen/xendomains.initd |   57 ++++++++++++++++++++++++++-------------------
 2 files changed, 35 insertions(+), 26 deletions(-)
 mode change 100644 => 100755 main/xen/xendomains.initd
diff --git a/main/xen/APKBUILD b/main/xen/APKBUILD
index d2ee0b6..1e4276a 100644
--- a/main/xen/APKBUILD
+++ b/main/xen/APKBUILD
_at_@ -3,7 +3,7 @@
 # Maintainer: William Pitcock <nenolod_at_dereferenced.org>
 pkgname=xen
 pkgver=4.1.2
-pkgrel=5
+pkgrel=6
 pkgdesc="Xen hypervisor"
 url="http://www.xen.org/"
 arch="x86 x86_64"
_at_@ -95,4 +95,4 @@ fa06495a175571f4aa3b6cb88937953e  librt.patch
 c31163a3cd6cf58b4e9cac0e96812d65  e1000.patch
 62b3c5a7cff38c12df2de89af5d83fa1  xencommons.initd
 b5bfc08b82bc0d21193714719a719798  xend.initd
-86e7923383a906404da321d1814657e9  xendomains.initd"
+1b85b1da6a23a377454910ad8ead35f2  xendomains.initd"
diff --git a/main/xen/xendomains.initd b/main/xen/xendomains.initd
old mode 100644
new mode 100755
index 0f309ef..93c190c
--- a/main/xen/xendomains.initd
+++ b/main/xen/xendomains.initd
_at_@ -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
_at_@ -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";
+        	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;
+        	echo "Could not find /proc/xen/privcmd";
+        	exit 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."
_at_@ -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
_at_@ -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."
_at_@ -101,5 +109,6 @@ stop() {
 }
 
 status() {
+	check_xen
 	/usr/sbin/$CMD list
 }
-- 
1.7.9
---
Unsubscribe:  alpine-devel+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-devel+help_at_lists.alpinelinux.org
---
Received on Tue Feb 21 2012 - 23:43:08 UTC