# them if necessary.
#
-# $Id: user-group,v 1.3 2001-01-07 12:45:38 thib Exp $
+# $Id: user-group,v 1.4 2001-01-27 15:32:46 thib Exp $
# take 3 arguments : username
# groupname
echo "no."
CMD=""
if useradd -D 2> /dev/null; then
- CMD="useradd -c 'fcron' fcron"
+ CMD="useradd -c '$USERNAME' $USERNAME"
elif adduser -D 2> /dev/null; then
- CMD="adduser -c 'fcron' fcron"
+ CMD="adduser -c '$USERNAME' $USERNAME"
fi
if test -z "$CMD"; then
echo "Could not determine the command to use to add a user."
echo "with configure script."
exit 1
fi
+
+
+INSTALL="nothing"
+INSTALLED=0
+CMD="groupadd $GROUPNAME"
+
+echo -n "Checking if $GROUPNAME is in /etc/group ... "
+if grep "^$GROUPNAME:" /etc/group > /dev/null; then
+ echo "yes."
+ INSTALLED=1
+else
+ echo "no."
+ if test -z "$CMD"; then
+ echo "Could not determine the command to use to add a group."
+ echo "Please add group \"GROUPNAME\" manually"
+ echo "(or choose another groupname with configure script)."
+ exit 1
+ fi
+ if test $ANSWER -eq 2; then
+ while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \);
+ do
+ echo "Would you like to add $GROUPNAME in /etc/passwd with the following command ?"
+ echo " $CMD"
+ read -p "Please answer with 'y' or 'n' (default: 'y'): " INSTALL NOTHING
+ done
+ if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then
+ if $CMD; then
+ INSTALLED=1
+ fi
+ fi
+ elif test $ANSWER -eq 1; then
+ # automatic answer given by configure script (option --with-answer-all)
+ if $CMD; then
+ INSTALLED=1
+ fi
+ fi
+fi
+
+
+if test $INSTALLED -eq 0; then
+ echo "Group $GROUPNAME does not exist : please create it or choose another groupname"
+ echo "with configure script."
+ exit 1
+fi