SHA256
1
0
forked from pool/xen
OBS User unknown
2007-05-22 23:45:46 +00:00
committed by Git OBS Bridge
parent 0a63222b01
commit 4246413f13
16 changed files with 2102 additions and 590 deletions

View File

@@ -1,9 +1,9 @@
#!/bin/bash
#
# xendomains Starts and stops secondary Xen domains
# xendomains Starts and stops Xen VMs
#
# chkconfig: 35 99 00
# description: Starts and stops secondary Xen domains
# description: Starts and stops Xen VMs
#
### BEGIN INIT INFO
# Provides: xendomains
@@ -13,19 +13,19 @@
# Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 4 6
# Short-Description: Starts and stops secondary Xen domains
# Description: Starts and stops secondary Xen domains automatically
# when domain 0 starts and stops.
# Short-Description: Starts and stops Xen VMs
# Description: Starts and stops Xen VMs automatically when the
# host starts and stops.
### END INIT INFO
# FIXME: Watch out for domain names with invalid characters.
. /etc/rc.status
rc_reset
LOCKFILE=/var/lock/subsys/xendomains
XENDOM_CONFIG=/etc/sysconfig/xendomains
RETCODE_FILE=/var/lock/subsys/xendomains.rc.$$
RETCODE_FILE=/tmp/xendomains.rc.$$
. "$XENDOM_CONFIG"
shopt -s dotglob nullglob
@@ -53,31 +53,33 @@ xendomains_abort()
rc_exit
}
if [ "$1" = status ]; then
if [ ! -e /proc/xen/privcmd ]; then
xendomains_abort 3
check()
{
XEND=`ps ax | grep -w xend | grep -w python | awk '{ print $1 }'`
XEND=`echo $XEND`
if [ "$1" = status ]; then
if [ ! -e /proc/xen/capabilities ] || [ ! -r "$XENDOM_CONFIG" ] || [ -z "$XEND" ]; then
xendomains_abort 3
fi
if [ ! -r "$XENDOM_CONFIG" ]; then
xendomains_abort 3
fi
else
if [ `id -u` != 0 ]; then
xendomains_abort 4
fi
if [ ! -e /proc/xen/privcmd ]; then
if [ "$1" = stop ] ||
[ "$1" = restart ]; then
xendomains_abort 0
else
else
if [ `id -u` != 0 ]; then
xendomains_abort 4
fi
if [ ! -e /proc/xen/capabilities ] || [ -z "$XEND" ] ||
! grep control_d /proc/xen/capabilities >/dev/null 2>&1; then
if [ "$1" = stop ] ||
[ "$1" = restart ]; then
xendomains_abort 0
else
xendomains_abort 6
fi
fi
if [ ! -r "$XENDOM_CONFIG" ]; then
xendomains_abort 6
fi
fi
if [ ! -r "$XENDOM_CONFIG" ]; then
xendomains_abort 6
fi
fi
. "$XENDOM_CONFIG"
}
dir_contains_something()
{
@@ -88,7 +90,7 @@ dir_contains_something()
get_name_from_cfg()
{
NM=`grep '^name[ ]*=' $1 | sed -e 's/^name[ ]*=[ ]*['\''"]\([^'\''"]*\)['\''"].*$/\1/'`
NM=`grep '^name[ ]*=' "$1" | sed -e 's/^name[ ]*=[ ]*['\''"]\([^'\''"]*\)['\''"].*$/\1/'`
}
running_auto_names()
@@ -120,6 +122,11 @@ parseln()
tm=`echo $tm`
}
xm_list()
{
TERM=vt100 xm list | grep -v '^Name *ID'
}
is_cfg_running()
{
get_name_from_cfg "$1"
@@ -130,7 +137,7 @@ is_cfg_running()
[ -z "$state" ] && return 1
return 0
fi
done < <(xm list | grep -v '^Name *ID')
done < <(xm_list)
return 1
}
@@ -204,7 +211,7 @@ any_non_zombies()
[ "$id" = 0 ] && continue
[ -z "$state" ] && continue
is_zombie_state "$state" || return 0
done < <(xm list | grep -v '^Name *ID')
done < <(xm_list)
return 1
}
@@ -368,7 +375,7 @@ stop()
fi
rc_status -v
fi
done < <(xm list | grep -v '^Name *ID')
done < <(xm_list)
if [ -n "$XENDOMAINS_SHUTDOWN_ALL" ] && any_non_zombies ; then
echo -n " others: shutting down... "
@@ -398,7 +405,7 @@ check_domain_up()
[ -z "$state" ] && return 1
return 0
fi
done < <(xm list | grep -v '^Name *ID')
done < <(xm_list)
return 1
}
@@ -440,18 +447,22 @@ restart()
case "$1" in
start)
check $1
start
;;
stop)
check $1
stop
;;
restart|reload)
check $1
restart
;;
try-restart)
check $1
"$0" status
if [ $? = 0 ]; then
"$0" restart
@@ -462,6 +473,7 @@ case "$1" in
;;
status)
check $1
echo -n "Checking status of Xen domains"
if [ ! -f "$LOCKFILE" ]; then
rc_failed 3