]> granicus.if.org Git - fcron/commitdiff
bug corrected: use $USERNAME instead of "fcron"
authorthib <thib>
Sat, 27 Jan 2001 15:32:46 +0000 (15:32 +0000)
committerthib <thib>
Sat, 27 Jan 2001 15:32:46 +0000 (15:32 +0000)
added code to add group fcron

script/user-group

index d960432951c22be075bfa2b0e587a65835d9acf1..27c48d722045ad0c5796c933e376afb4b55ad02c 100755 (executable)
@@ -4,7 +4,7 @@
 #  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
@@ -31,9 +31,9 @@ else
   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."
@@ -67,3 +67,47 @@ if test $INSTALLED -eq 0; then
   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