3 # util-vserver: sets the path to vshelper and kills all guest processes
5 # chkconfig: 2345 10 70
6 # description: Sets the path to vshelper and kills all guest processes
8 # if kernel not capable, exit early
9 if [ ! -d /proc/virtual ]; then
11 start|stop|reload|force-reload|restart)
17 # Source function library
18 . /etc/rc.d/init.d/functions
20 [ -n "$UTIL_VSERVER_VARS" ] || UTIL_VSERVER_VARS=/usr/lib/util-vserver/util-vserver-vars
21 if [ ! -e "$UTIL_VSERVER_VARS" ] ; then
22 echo "Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
25 . "$UTIL_VSERVER_VARS"
29 show "Setting path to vshelper"
30 if [ -e /proc/sys/kernel/vshelper ]; then
31 echo "$_VSHELPER" >/proc/sys/kernel/vshelper
38 run_cmd "Loading default device map" $__PKGLIBDIR/bash-wrapper "handleDeviceMap --set 0 $__CONFDIR/.defaults/apps/vdevmap"
40 [ "$RETVAL" -eq 0 -a "$RETVAL1" -eq 0 ] && touch /var/lock/subsys/util-vserver
43 # Stop all running, but non-default guests"
46 run_cmd "Stopping all running guests" $_START_VSERVERS -j 1 --all --stop
48 xids=$(ls -1 /proc/virtual 2>/dev/null | egrep -v 'info|status' 2>/dev/null)
49 if [ -n "$xids" ]; then
50 show "Sending all contexts the TERM signal"
52 $_VATTRIBUTE --xid $xid --set --flag ~persistent
53 $_VKILL --xid $xid -s 15
55 xids=$(ls -1 /proc/virtual 2>/dev/null | egrep -v 'info|status' 2>/dev/null)
56 if [ -n "$xids" ]; then
62 if [ -n "$xids" ]; then
64 show "Sending all contexts the KILL signal"
66 $_VATTRIBUTE --xid $xid --set --flag ~persistent
67 $_VKILL --xid $xid -s 9
69 xids=$(ls -1 /proc/virtual 2>/dev/null | egrep -v 'info|status' 2>/dev/null)
70 if [ -n "$xids" ]; then
76 rm -f /var/lock/subsys/util-vserver >/dev/null 2>&1
80 # See how we were called.
88 # restart behaves like reload because a stop-start sequence
89 # would kill all running vservers AND would not start them
90 restart|reload|force-reload)
92 [ $? -ne 0 ] && RETVAL=7
95 if [ -e /proc/sys/kernel/vshelper ]; then
96 read _vsh </proc/sys/kernel/vshelper
97 show "Path to vshelper: $_vsh, expected: $_VSHELPER"
98 if [ "$_vsh" = "$_VSHELPER" ]; then
110 msg_usage "$0 {start|stop|restart|reload|force-reload|status}"