save_config() {
echo "# Configuration file for adduser(8)." > ${ADDUSERCONF}
echo "# NOTE: only *some* variables are saved." >> ${ADDUSERCONF}
- echo "# Last Modified on `date`." >> ${ADDUSERCONF}
+ echo "# Last Modified on `${DATECMD}`." >> ${ADDUSERCONF}
echo '' >> ${ADDUSERCONF}
echo "defaultclass=$uclass" >> ${ADDUSERCONF}
echo "defaultgroups=$ugroups" >> ${ADDUSERCONF}
_upasswd=
_passwdmethod=
- _name="-n $username"
- [ -n "$uuid" ] && _uid="-u $uuid"
- [ -n "$ulogingroup" ] && _group="-g $ulogingroup"
- [ -n "$ugroups" ] && _grouplist="-G $ugroups"
- [ -n "$ushell" ] && _shell="-s $ushell"
- [ -n "$uhome" ] && _home="-m -d $uhome"
- [ -n "$uclass" ] && _class="-L $uclass"
+ _name="-n '$username'"
+ [ -n "$uuid" ] && _uid="-u '$uuid'"
+ [ -n "$ulogingroup" ] && _group="-g '$ulogingroup'"
+ [ -n "$ugroups" ] && _grouplist="-G '$ugroups'"
+ [ -n "$ushell" ] && _shell="-s '$ushell'"
+ [ -n "$uhome" ] && _home="-m -d '$uhome'"
+ [ -n "$uclass" ] && _class="-L '$uclass'"
[ -n "$ugecos" ] && _comment="-c '$ugecos'"
- [ -n "$udotdir" ] && _dotdir="-k $udotdir"
+ [ -n "$udotdir" ] && _dotdir="-k '$udotdir'"
[ -n "$uexpire" ] && _expire="-e '$uexpire'"
[ -n "$upwexpire" ] && _pwexpire="-p '$upwexpire'"
case $passwdtype in
yes)
_passwdmethod="-w yes"
_passwd="-h 0"
- _upasswd="echo $upass |"
+ _upasswd="echo '$upass' |"
;;
none)
_passwdmethod="-w none"
ushell="$defaultshell"
# Make sure the current value of the shell is a valid one
- _shellchk="grep '^$ushell$' ${ETCSHELLS} > /dev/null 2>&1"
+ _shellchk="${GREPCMD} '^$ushell$' ${ETCSHELLS} > /dev/null 2>&1"
eval $_shellchk || {
err "Invalid shell ($ushell). Using default shell ${defaultshell}."
ushell="$defaultshell"
_prompt="Uid (Leave empty for default): "
fi
if [ -z "$fflag" ]; then
- echo -n $_prompt
+ echo -n "$_prompt"
read _input
else
_input="`echo "$fileline" | cut -f2 -d:`"
;;
esac
passwdtype="yes"
+ [ -n "$configrun" ] && break
trap 'stty echo; exit' 0 1 2 3 15
stty -echo
echo -n "Enter password: "
_pass='<random>'
;;
esac
- printf "%-10s : %s\n" "Password" "$_pass"
+ [ -z "$configflag" ] && printf "%-10s : %s\n" "Password" "$_pass"
+ [ -n "$configflag" ] && printf "%-10s : %s\n" "Pass Type" "$passwdtype"
[ -z "$configflag" ] && printf "%-10s : %s\n" "Full Name" "$ugecos"
[ -z "$configflag" ] && printf "%-10s : %s\n" "Uid" "$uuid"
printf "%-10s : %s\n" "Class" "$uclass"
PWCMD="${PWCMD:-/usr/sbin/pw}"
MAILCMD="${MAILCMD:-mail}"
ETCSHELLS="${ETCSHELLS:-/etc/shells}"
+GREPCMD="/usr/bin/grep"
+DATECMD="/bin/date"
# Set default values
#
fi
else
input_interactive
+ while : ; do
+ echo -n "Add another user? (yes/no): "
+ read _input
+ case $_input in
+ [Yy][Ee][Ss]|[Yy][Ee]|[Yy])
+ uidstart=`get_nextuid $uidstart`
+ input_interactive
+ continue
+ ;;
+ [Nn][Oo]|[Nn])
+ echo "Goodbye!"
+ ;;
+ *)
+ continue
+ ;;
+ esac
+ break
+ done
fi