summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author Robby Workman <rworkman@slackbuilds.org>2014-12-20 05:46:35 (GMT)
committer Robby Workman <rworkman@slackbuilds.org>2014-12-20 05:49:59 (GMT)
commitbb44a8de7f7927a431c49c13416d49e2f670d8e6 (patch)
tree4fc671cfe688e6e8bcb6b87a94a5892e6e864da4
parent2f76ab04895bc5154664120a43568c6d28b1581f (diff)
downloadslackbuilds-rworkman.tar.gz
slackbuilds-rworkman.tar.xz
libraries/libvirt: Make rc.libvirt more robustrworkman
Detecting running domains by grepping for "running" isn't very effective for non-english strings, so let's fix that. Since I was already there, I cleaned up a few more nits. Thanks to Mathieu Bouillaguet for the report and solution. TODO: use --with-qemu-user=qemu and --with-qemu-group=qemu per upstream recommendation; this will have to be in sync with the qemu build here (with respect to what actual user and group names are used) Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
-rw-r--r--libraries/libvirt/libvirt.SlackBuild2
-rw-r--r--libraries/libvirt/rc.libvirt30
2 files changed, 16 insertions, 16 deletions
diff --git a/libraries/libvirt/libvirt.SlackBuild b/libraries/libvirt/libvirt.SlackBuild
index c8a17ff..aee6263 100644
--- a/libraries/libvirt/libvirt.SlackBuild
+++ b/libraries/libvirt/libvirt.SlackBuild
@@ -6,7 +6,7 @@
PRGNAM=libvirt
VERSION=${VERSION:-1.2.11}
-BUILD=${BUILD:-1}
+BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
diff --git a/libraries/libvirt/rc.libvirt b/libraries/libvirt/rc.libvirt
index d8ddd63..19bf665 100644
--- a/libraries/libvirt/rc.libvirt
+++ b/libraries/libvirt/rc.libvirt
@@ -18,31 +18,31 @@ OPTS=${OPTS:-" -v -f /etc/libvirt/libvirtd.conf -p $PIDFILE "}
check_running_machines() {
- i=0
+ count=0
- for j in `/usr/sbin/virsh list | grep running | awk '{print $2;}'` ; do
- /usr/sbin/virsh shutdown $j
+ for machine in $(virsh list --name --state-running | grep -v ^$) ; do
+ /usr/sbin/virsh shutdown $machine
done
echo -n "Waiting machines"
- while [ $(/usr/sbin/virsh list | grep running | wc -l) -gt "0" ]; do
- if [ "$i" -ge "$TIMEOUT" ];then
+ while [ $(virsh list --name --state-running | grep -v ^$ | wc -l) -gt "0" ]; do
+ if [ "$count" -ge "$TIMEOUT" ];then
break
fi
echo -n "."
- i=`expr $i + 1`
+ count=$(expr $count + 1)
sleep 1
done
echo ""
- if [ $(/usr/sbin/virsh list | grep running | wc -l) -gt "0" ];then
+ if [ $(virsh list --name --state-running | grep -v ^$ | wc -l) -gt "0" ];then
echo -n "The following machines are still running, forcing shutdown: "
- for j in `/usr/sbin/virsh list | grep running | awk '{print $2;}'` ; do
- /usr/sbin/virsh destroy $j
- echo -n "$j "
+ for machine in $(virsh list --name --state-running | grep -v ^$) ; do
+ /usr/sbin/virsh destroy $machine
+ echo -n "$machine "
done
echo ""
@@ -67,10 +67,10 @@ check_processor() {
MODULES="$MODULES kvm_amd kvm"
fi
- check=`expr $check + $?`
+ check=$(expr $check + $?)
if [ $check -eq "2" ];then
- echo "Your systems does not support KVM!"
+ echo "Your system does not support KVM!"
fi
}
@@ -95,10 +95,10 @@ stop() {
check_running_machines
check_processor
echo "Stopping libvirtd..."
- for i in $(/usr/sbin/virsh net-list | tail -n +3 | awk '{print $1}'); do
- /usr/sbin/virsh net-destroy "$i"
+ for network in $(/usr/sbin/virsh net-list | tail -n +3 | awk '{print $1}'); do
+ /usr/sbin/virsh net-destroy "$network"
done
- kill -TERM `cat $PIDFILE`
+ kill -TERM $(cat $PIDFILE)
sleep 3
/sbin/modprobe -ra $MODULES 2>/dev/null
}