#!/bin/sh # # util-vserver: sets the path to vshelper and kills all guest processes # # chkconfig: 2345 10 99 # description: Sets the path to vshelper and kills all guest processes # if kernel not capable, exit early if [ ! -d /proc/virtual ]; then case "$1" in start|stop|reload|force-reload|restart) exit 0 ;; esac fi # Source function library . /etc/rc.d/init.d/functions [ -n "$UTIL_VSERVER_VARS" ] || UTIL_VSERVER_VARS=/usr/lib/util-vserver/util-vserver-vars if [ ! -e "$UTIL_VSERVER_VARS" ] ; then echo "Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2 exit 1 fi . "$UTIL_VSERVER_VARS" start() { show "Setting path to vshelper" if [ -e /proc/sys/kernel/vshelper ]; then echo "$_VSHELPER" >/proc/sys/kernel/vshelper ok RETVAL1=0 else fail RETVAL1=1 fi run_cmd "Loading default device map" $__PKGLIBDIR/bash-wrapper "handleDeviceMap --set 0 $__CONFDIR/.defaults/apps/vdevmap" RETVAL=$? [ "$RETVAL" -eq 0 -a "$RETVAL1" -eq 0 ] && touch /var/lock/subsys/util-vserver } # Stop all running, but non-default guests" stop() { run_cmd "Stopping all running guests" $_START_VSERVERS -j 1 --all --stop xids=$(ls -1 /proc/virtual 2>/dev/null | egrep -v 'info|status' 2>/dev/null) if [ -n "$xids" ]; then show "Sending all contexts the TERM signal" for xid in $xids; do $_VATTRIBUTE --xid $xid --set --flag ~persistent $_VKILL --xid $xid -s 15 done xids=$(ls -1 /proc/virtual 2>/dev/null | egrep -v 'info|status' 2>/dev/null) if [ -n "$xids" ]; then fail else ok fi fi if [ -n "$xids" ]; then sleep 5 show "Sending all contexts the KILL signal" for xid in $xids; do $_VATTRIBUTE --xid $xid --set --flag ~persistent $_VKILL --xid $xid -s 9 done xids=$(ls -1 /proc/virtual 2>/dev/null | egrep -v 'info|status' 2>/dev/null) if [ -n "$xids" ]; then fail else ok fi fi rm -f /var/lock/subsys/util-vserver >/dev/null 2>&1 } RETVAL=0 # See how we were called. case "$1" in start) start ;; stop) stop ;; # restart behaves like reload because a stop-start sequence # would kill all running vservers AND would not start them restart|reload|force-reload) start [ $? -ne 0 ] && RETVAL=7 ;; status) if [ -e /proc/sys/kernel/vshelper ]; then read _vsh