From: thib Date: Thu, 1 Mar 2001 18:39:03 +0000 (+0000) Subject: make user fcron be in group fcron (and check if it is really the case) as it is neede... X-Git-Tag: ver1564~321 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7efc54627c37ead3e1be87f2616b45b39e798080;p=fcron make user fcron be in group fcron (and check if it is really the case) as it is needed by fcron to run correctly. --- diff --git a/script/user-group b/script/user-group index d2a88b6..9b5eb4e 100755 --- a/script/user-group +++ b/script/user-group @@ -4,7 +4,7 @@ # them if necessary. # -# $Id: user-group,v 1.6 2001-02-14 13:48:30 thib Exp $ +# $Id: user-group,v 1.7 2001-03-01 18:39:03 thib Exp $ # take 3 arguments : username # groupname @@ -20,39 +20,32 @@ fi USERNAME=$1 GROUPNAME=$2 ANSWER=$3 + INSTALL="nothing" INSTALLED=0 -if test `uname -s` = "FreeBSD"; then - IS_FREEBSD=1 +if test $IS_FREEBSD -eq 1; then + CMD="pw groupadd $GROUPNAME" else - IS_FREEBSD=0 + CMD="groupadd $GROUPNAME" fi -echo -n "Checking if $USERNAME is in /etc/passwd ... " -if grep "^$USERNAME:" /etc/passwd > /dev/null; then +echo -n "Checking if $GROUPNAME is in /etc/group ... " +if grep "^$GROUPNAME:" /etc/group > /dev/null; then echo "yes." INSTALLED=1 else echo "no." - CMD="" - if useradd -D 2> /dev/null; then - CMD="useradd -c '$USERNAME' $USERNAME" - elif adduser -D 2> /dev/null; then - CMD="adduser -c '$USERNAME' $USERNAME" - elif test $IS_FREEBSD -eq 1; then - CMD="pw useradd $USERNAME -c $USERNAME" - fi if test -z "$CMD"; then - echo "Could not determine the command to use to add a user." - echo "Please add user \"$USERNAME\" (group \"GROUPNAME\") manually" - echo "(or choose another username with configure script)." + 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 $USERNAME in /etc/passwd with the following command ?" + echo "Would you like to add $GROUPNAME in /etc/passwd with the following command ?" echo " $CMD" echo -n "Please answer with 'y' or 'n' (default: 'y'): " read INSTALL NOTHING @@ -72,37 +65,49 @@ fi if test $INSTALLED -eq 0; then - echo "User $USERNAME does not exist : please create it or choose another username" + echo + echo "Group \"$GROUPNAME\" does not exist : please create it or choose another groupname" echo "with configure script." exit 1 fi +# get the gid value : +GID="`cat /etc/group | grep fcron | awk -F ":" '{print $3}'`" + INSTALL="nothing" INSTALLED=0 -if test $IS_FREEBSD -eq 1; then - CMD="pw groupadd $GROUPNAME" +if test `uname -s` = "FreeBSD"; then + IS_FREEBSD=1 else - CMD="groupadd $GROUPNAME" + IS_FREEBSD=0 fi -echo -n "Checking if $GROUPNAME is in /etc/group ... " -if grep "^$GROUPNAME:" /etc/group > /dev/null; then +echo -n "Checking if $USERNAME is in /etc/passwd ... " +if grep "^$USERNAME:" /etc/passwd > /dev/null; then echo "yes." INSTALLED=1 else echo "no." + CMD="" + if useradd -D 2> /dev/null; then + CMD="useradd -c '$USERNAME' -g $GROUPNAME $USERNAME" + elif adduser -D 2> /dev/null; then + CMD="adduser -c '$USERNAME' -g $GROUPNAME $USERNAME" + elif test $IS_FREEBSD -eq 1; then + CMD="pw useradd $USERNAME -c $USERNAME" + fi 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)." + echo "Could not determine the command to use to add a user." + echo "Please add user \"$USERNAME\" (group \"GROUPNAME\") manually" + echo "(or choose another username 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 "Would you like to add $USERNAME in /etc/passwd with the following command ?" echo " $CMD" echo -n "Please answer with 'y' or 'n' (default: 'y'): " read INSTALL NOTHING @@ -122,7 +127,17 @@ fi if test $INSTALLED -eq 0; then - echo "Group $GROUPNAME does not exist : please create it or choose another groupname" + echo + echo "User \"$USERNAME\" does not exist : please create it or choose another username" echo "with configure script." exit 1 +else + USERGID="`cat /etc/passwd | grep fcron | awk -F ':' '{print $4}'`" + if test "$GID" -ne "$USERGID"; then + echo + echo "User $USERNAME exists, but is not in the group $GROUPNAME." + echo "Please set its group to \"$GROUPNAME\" (id $GID) manually." + exit 1 + fi fi +