From 15cbf3119e82f12b2dbf2d86bc23ffcc885ec83e Mon Sep 17 00:00:00 2001 From: Thibault Godouet Date: Sun, 7 Jan 2001 12:44:58 +0000 Subject: [PATCH] added ./configure's option --with-answer-all --- script/boot-install | 233 +++++++++++++++++++++++++------------------- script/user-group | 69 +++++++------ 2 files changed, 171 insertions(+), 131 deletions(-) diff --git a/script/boot-install b/script/boot-install index 4df32db..ae1e8e4 100755 --- a/script/boot-install +++ b/script/boot-install @@ -2,16 +2,18 @@ # Install fcron under SysV system. # -# $Id: boot-install,v 1.19 2001-01-04 15:50:15 thib Exp $ +# $Id: boot-install,v 1.20 2001-01-07 12:44:58 thib Exp $ -# take 4 arguments : the name of the BSD-like install program (with "-o" and the correct username) -# the DESTSBIN directory, the value of DEBUG -# and the value of FCRONTABS +# take 5 arguments : the name of the BSD-like install program (with "-o" and the correct username) +# the DESTSBIN directory +# the value of DEBUG +# the value of FCRONTABS +# the automatic answer PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin" startdir=$pwd -if test $# -ne 4; then +if test $# -ne 5; then echo "Too few/many arguments" exit 1 fi @@ -22,7 +24,7 @@ fi #DEBUG=$3 DEBUG=1 FCRONTABS=$4 -echo "fcrontab $FCRONTABS" +ANSWER=$5 if test $DEBUG -eq 1; then STARTCMD="fcron -b -d" @@ -41,27 +43,36 @@ RESTARTED=0 INSTALLED=0 if test -f /etc/rc.d/rc.M; then - # Slackware - if ! cat /etc/rc.d/rc.local | grep "$STARTCMD"; then - while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \); - do - echo "Would you like to add $STARTCMD in the file /etc/rc.d/rc.local ?" - read -p "Please answer with 'y' or 'n' (default: 'y'): " INSTALL NOTHING - done - if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then - echo $STARTCMD >> /etc/rc.d/rc.local - INSTALLED=1 - else - INSTALLED=0 - fi - elif cat /etc/rc.d/rc.local | grep fcron; then + # Slackware + if ! cat /etc/rc.d/rc.local | grep "$STARTCMD"; then + if cat /etc/rc.d/rc.local | grep fcron; then echo "Fcron seems to be in /etc/rc.d/rc.local, but not with the appropriate options :" echo "you should probably correct this file in order to run fcron with $STARTCMD." INSTALLED=1 else - echo "Fcron is already in /etc/rc.d/rc.local." - INSTALLED=1 + if test $ANSWER -eq 2; then + while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \); + do + echo "Would you like to add $STARTCMD in the file /etc/rc.d/rc.local ?" + read -p "Please answer with 'y' or 'n' (default: 'y'): " INSTALL NOTHING + done + # automatic answer given by configure script (option --with-answer-all) + elif test $ANSWER -eq 1; then + INSTALL="y" + else + INSTALL="n" + fi + if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then + echo $STARTCMD >> /etc/rc.d/rc.local + INSTALLED=1 + else + INSTALLED=0 + fi fi + else + echo "Fcron is already in /etc/rc.d/rc.local." + INSTALLED=1 + fi fi @@ -73,64 +84,80 @@ elif test -d /etc/init.d/; then ROOTDIR="/etc" fi if test \( ! "$INSTALLED" -eq 1 \) -a \( "$ROOTDIR" != "" \); then + if test $ANSWER -eq 2; then while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \); - do + do echo "Would you like to add fcron in the directory $ROOTDIR/init.d/ and in runlevel 2, 3, 4 and 5" echo "(directories $ROOTDIR/rc{2,3,4,5}.d/) ?" read -p "Please answer with 'y' or 'n' (default: 'y'): " INSTALL NOTHING - done - if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then - $1 -c -m 755 script/sysVinit-launcher $ROOTDIR/init.d/fcron - if test $DEBUG -eq 1; then - cat $ROOTDIR/init.d/fcron | sed 's: -b: -b -d:' >$ROOTDIR/init.d/fcron2 - mv -f $ROOTDIR/init.d/fcron2 $ROOTDIR/init.d/fcron - chmod +x $ROOTDIR/init.d/fcron - fi - cat $ROOTDIR/init.d/fcron | sed "s:@@DESTSBIN@:$2:" >$ROOTDIR/init.d/fcron2 + done + # automatic answer given by configure script (option --with-answer-all) + elif test $ANSWER -eq 1; then + INSTALL="y" + else + INSTALL="n" + fi + if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then + $1 -c -m 755 script/sysVinit-launcher $ROOTDIR/init.d/fcron + if test $DEBUG -eq 1; then + cat $ROOTDIR/init.d/fcron | sed 's: -b: -b -d:' >$ROOTDIR/init.d/fcron2 mv -f $ROOTDIR/init.d/fcron2 $ROOTDIR/init.d/fcron chmod +x $ROOTDIR/init.d/fcron - - cd $ROOTDIR/rc2.d/ ; ln -f -s ../init.d/fcron S40fcron - cd $ROOTDIR/rc3.d/ ; ln -f -s ../init.d/fcron S40fcron - cd $ROOTDIR/rc4.d/ ; ln -f -s ../init.d/fcron S40fcron - cd $ROOTDIR/rc5.d/ ; ln -f -s ../init.d/fcron S40fcron - - cd $ROOTDIR/rc0.d/ ; ln -f -s ../init.d/fcron K60fcron - cd $ROOTDIR/rc6.d/ ; ln -f -s ../init.d/fcron K60fcron - cd $startdir - - INSTALLED=1 - SYSV=1 - else - INSTALLED=0 fi + cat $ROOTDIR/init.d/fcron | sed "s:@@DESTSBIN@:$2:" >$ROOTDIR/init.d/fcron2 + mv -f $ROOTDIR/init.d/fcron2 $ROOTDIR/init.d/fcron + chmod +x $ROOTDIR/init.d/fcron + + cd $ROOTDIR/rc2.d/ ; ln -f -s ../init.d/fcron S40fcron + cd $ROOTDIR/rc3.d/ ; ln -f -s ../init.d/fcron S40fcron + cd $ROOTDIR/rc4.d/ ; ln -f -s ../init.d/fcron S40fcron + cd $ROOTDIR/rc5.d/ ; ln -f -s ../init.d/fcron S40fcron + + cd $ROOTDIR/rc0.d/ ; ln -f -s ../init.d/fcron K60fcron + cd $ROOTDIR/rc6.d/ ; ln -f -s ../init.d/fcron K60fcron + cd $startdir + + INSTALLED=1 + SYSV=1 + else + INSTALLED=0 + fi fi INSTALL="nothing" if test \( ! "$INSTALLED" -eq 1 \) -a \( -f /etc/rc \) ; then - # FreeBSD - if ! cat /etc/rc.local | grep "$STARTCMD"; then - while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \); - do - echo "Would you like to add $STARTCMD in the file /etc/rc.local ?" - read -p "Please answer with 'y' or 'n' (default: 'y'): " INSTALL NOTHING - done - if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then - echo $STARTCMD >> /etc/rc.local - INSTALLED=1 - else - INSTALLED=0 - fi - elif cat /etc/rc.local | grep fcron; then + # FreeBSD + if ! cat /etc/rc.local | grep "$STARTCMD"; then + if cat /etc/rc.local | grep fcron; then echo "Fcron seems to be in /etc/rc.local, but not with the appropriate options :" echo "you should probably correct this file in order to run fcron with $STARTCMD." INSTALLED=1 else - echo "Fcron is already in /etc/rc.local." - INSTALLED=1 + if test $ANSWER -eq 2; then + while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \); + do + echo "Would you like to add $STARTCMD in the file /etc/rc.local ?" + read -p "Please answer with 'y' or 'n' (default: 'y'): " INSTALL NOTHING + done + # automatic answer given by configure script (option --with-answer-all) + elif test $ANSWER -eq 1; then + INSTALL="y" + else + INSTALL="n" + fi + if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then + echo $STARTCMD >> /etc/rc.local + INSTALLED=1 + else + INSTALLED=0 + fi fi + else + echo "Fcron is already in /etc/rc.local." + INSTALLED=1 + fi fi @@ -153,29 +180,27 @@ if test -z "$PID"; then RESTARTED=1 else if test "$SYSV" -eq 1; then - while test \( ! -z "$RESTART" \) -a \( "$RESTART" != "y" \) -a \( "$RESTART" != "n" \); - do - echo "Would you like to do it with a 'kill -TERM \`pidof fcron\`'" - echo "followed by a '"$ROOTDIR"/init.d/fcron start' ?" - read -p "Please answer with 'y' or 'n' (default: 'y'): " RESTART NOTHING - done - if test \( -z "$RESTART" \) -o \( "$RESTART" = "y" \); then - $KILL - $ROOTDIR/init.d/fcron start - RESTARTED=1 - fi + CMD="$ROOTDIR/init.d/fcron start" else - while test \( ! -z "$RESTART" \) -a \( "$RESTART" != "y" \) -a \( "$RESTART" != "n" \); - do - echo "Would you like to do it with a 'kill -TERM \`pidof fcron\`'" - echo "followed by a '"$STARTCMD"' ?" - read -p "Please answer with 'y' or 'n' (default: 'y'): " RESTART NOTHING - done - if test \( -z "$RESTART" \) -o \( "$RESTART" = "y" \); then - $KILL - $STARTCMD - RESTARTED=1 - fi + CMD=$STARTCMD + fi + if test $ANSWER -eq 2; then + while test \( ! -z "$RESTART" \) -a \( "$RESTART" != "y" \) -a \( "$RESTART" != "n" \); + do + echo "Would you like to do it with a 'kill -TERM \`pidof fcron\`'" + echo "followed by a '"$CMD"' ?" + read -p "Please answer with 'y' or 'n' (default: 'y'): " RESTART NOTHING + done + # automatic answer given by configure script (option --with-answer-all) + elif test $ANSWER -eq 1; then + RESTART="y" + else + RESTART="n" + fi + if test \( -z "$RESTART" \) -o \( "$RESTART" = "y" \); then + $KILL + $CMD + RESTARTED=1 fi fi @@ -190,25 +215,31 @@ echo "version of fcrontab may not work with this version if you don't" echo "reinstall them." if test "$RESTARTED" -eq 1; then - REINSTALL="nothing" - # reinstall the fcrontabs - # to do that, the old (if any) version of fcron must not run - # (sysVinit-install normally start the last version) + REINSTALL="nothing" + # reinstall the fcrontabs + # to do that, the old (if any) version of fcron must not run + # (sysVinit-install normally start the last version) + if test $ANSWER -eq 2; then while test \( ! -z "$REINSTALL" \) -a \( "$REINSTALL" != "y" \) -a \( "$REINSTALL" != "n" \); - do + do echo "Would you like to do it now ?" read -p "Please answer with 'y' or 'n' (default: 'y'): " REINSTALL NOTHING - done - if test \( -z "$REINSTALL" \) -o \( "$REINSTALL" = "y" \); then - for FILE in $FCRONTABS/* ; do \ - if test "$FILE" != "$FCRONTABS/*"; then - BASENAME=`basename $FILE` ; \ - FCRONTAB=`echo "$BASENAME" | \ - sed "s|.*orig|| ; s|new.*|| ; s|fcrontab.sig|| ; s|rm.*||"` ; \ - ( test ! -z "$FCRONTAB" && fcrontab -u $FCRONTAB -z ) \ - || echo -n ""; \ - fi - done - fi + done + elif test $ANSWER -eq 1; then + REINSTALL="y" + else + REINSTALL="n" + fi + if test \( -z "$REINSTALL" \) -o \( "$REINSTALL" = "y" \); then + for FILE in $FCRONTABS/* ; do \ + if test "$FILE" != "$FCRONTABS/*"; then + BASENAME=`basename $FILE` ; \ + FCRONTAB=`echo "$BASENAME" | \ + sed "s|.*orig|| ; s|new.*|| ; s|fcrontab.sig|| ; s|rm.*||"` ; \ + ( test ! -z "$FCRONTAB" && fcrontab -u $FCRONTAB -z ) \ + || echo -n ""; \ + fi + done + fi fi diff --git a/script/user-group b/script/user-group index 77b29eb..d960432 100755 --- a/script/user-group +++ b/script/user-group @@ -4,57 +4,66 @@ # them if necessary. # -# $Id: user-group,v 1.2 2001-01-04 15:50:41 thib Exp $ +# $Id: user-group,v 1.3 2001-01-07 12:45:38 thib Exp $ -# take 2 arguments : username +# take 3 arguments : username # groupname +# automatic answer PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin" -if test $# -ne 2; then +if test $# -ne 3; then echo "Too few/many arguments" exit 1 fi USERNAME=$1 GROUPNAME=$2 +ANSWER=$3 INSTALL="nothing" INSTALLED=0 echo -n "Checking if $USERNAME is in /etc/passwd ... " if grep "^$USERNAME:" /etc/passwd > /dev/null; then - echo "yes." - INSTALLED=1 + echo "yes." + INSTALLED=1 else - echo "no." - CMD="" - if useradd -D 2> /dev/null; then - CMD="useradd -c 'fcron' fcron" - elif adduser -D 2> /dev/null; then - CMD="adduser -c 'fcron' fcron" - 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)." - exit 1 - fi + echo "no." + CMD="" + if useradd -D 2> /dev/null; then + CMD="useradd -c 'fcron' fcron" + elif adduser -D 2> /dev/null; then + CMD="adduser -c 'fcron' fcron" + 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)." + 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 " $CMD" - read -p "Please answer with 'y' or 'n' (default: 'y'): " INSTALL NOTHING - done + do + echo "Would you like to add $USERNAME 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 + 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 "User $USERNAME does not exist : please create it or choose another username" - echo "with configure script." - exit 1 + echo "User $USERNAME does not exist : please create it or choose another username" + echo "with configure script." + exit 1 fi -- 2.47.3