3 # userdel(8) wrapper for vservers
5 # Copyright (c) 2004 The Trustees of Princeton University (Trustees).
7 # $Id: vuserdel,v 1.7 2005/04/07 19:37:25 smuir Exp $
10 : ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
11 test -e "$UTIL_VSERVER_VARS" || {
12 echo "Can not find util-vserver installation; aborting..."
15 . "$UTIL_VSERVER_VARS"
24 [ "$1" == "--static" ] && { STATIC=yes; shift; }
27 # read config file to get context ID
28 . /etc/vservers/$NAME.conf
31 # don't bother stopping gracefully, just kill all the processes
32 $SBINDIR/chcontext --silent --secure --ctx $CTX $PKGLIBDIR/vserverkillall
34 # unmount any directories in vserver that are mount points
35 for d in `sed -ne "s%^[^ ]* \($VROOTDIR/$NAME/[^ ]*\) .*%\1%p" /proc/mounts`
37 # use echo -e to turn escaped whitespace back into regular chars
38 # be careful about embedded backquotes here (i think we're safe)
40 echo "unmounting $dir"
44 # turn resource management off for vserver $NAME
45 service resman stop $NAME
46 # XXX - resman doesn't print a trailing newline
50 [ -z "$STATIC" ] && userdel -r $NAME
52 # remove vserver configuration file
53 rm -f /etc/vservers/$NAME.conf
55 # remove vserver profile
56 rm -f /var/run/vservers/$NAME.ctx
59 if [ -d $VROOTDIR/$NAME ] ; then
60 TMP=$(mktemp -d "$VROOTDIR/.vtmp/$NAME.XXXXXX")
61 mv "$VROOTDIR/$NAME" "$TMP"