From 8314b3a832154ea55b7d0cadb80ba04ccfd581bc Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Fri, 27 Aug 2004 16:34:37 +0000 Subject: [PATCH] - group names have a 16 character maximum limit. Since I can't see a reason for slices to need custom group names, just assign them to the "slices" group. - do a basic sanity check on the new vserver: see if the apparent disk usage of the new vserver is less than that of the reference image. --- scripts/vuseradd | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/vuseradd b/scripts/vuseradd index 370d855..ef264a6 100755 --- a/scripts/vuseradd +++ b/scripts/vuseradd @@ -4,7 +4,7 @@ # # Copyright (c) 2004 The Trustees of Princeton University (Trustees). # -# $Id: vuseradd,v 1.5 2004/08/26 16:51:11 mlh-pl_kernel Exp $ +# $Id: vuseradd,v 1.6 2004/08/26 22:28:49 mlh-pl_kernel Exp $ # : ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars} @@ -23,18 +23,18 @@ usage() [ -z "$1" ] && usage NAME=$1 -# add user -useradd -s /bin/vsh $NAME +# add slices group if not already present +groupadd slices 2>/dev/null || : -# change shell (in case user already exists) -usermod -s /bin/vsh $NAME +# add user +useradd -g slices -s /bin/vsh $NAME # automount keys (eval expands ~) eval rm -rf ~$NAME/.ssh eval ln -nsf /var/pl_sshd/keys/$NAME ~$NAME/.ssh USERID=$(awk -F: "\$1 == \"$NAME\" { print \$3 }" < /etc/passwd) -GROUPID=$(awk -F: "\$1 == \"$NAME\" { print \$3 }" < /etc/passwd) +GROUPID=$(awk -F: "\$1 == \"slices\" { print \$3 }" < /etc/group) # create vserver configuration file if [ ! -f /etc/vservers/$NAME.conf ] ; then @@ -58,12 +58,14 @@ if [ ! -d "$VROOTDIR/$NAME" ] ; then "$PKGLIBDIR/vbuild" "$VROOTDIR/vserver-reference" "$TMP" RETVAL=$? # move it to .vcache when complete - if [ $RETVAL -eq 0 ] ; then - mv "$TMP" "$VROOTDIR/$NAME" - else + if [ $RETVAL -ne 0 ] || \ + [ $(du -s "$TMP" | awk "{ print \$1 }") -lt \ + $(du -s "$VROOTDIR/vserver-reference" | awk "{ print \$1 }") ] ; then echo "Error $RETVAL building $VROOTDIR/$NAME" rm -rf "$TMP" exit $RETVAL + else + mv "$TMP" "$VROOTDIR/$NAME" fi fi fi @@ -73,6 +75,6 @@ if [ -d "$VROOTDIR/$NAME" ] ; then chmod 755 "$VROOTDIR/$NAME" # add user in vserver - vserver $NAME suexec root groupadd -g $GROUPID $NAME + vserver $NAME suexec root groupadd -g $GROUPID slices vserver $NAME suexec root useradd -u $USERID -g $GROUPID -p '' $NAME fi -- 2.43.0