#if [ $LOGNAME. != new. ]
#then
#  echo
#  echo "This function is intended for new users only."
#  exit 1
#fi
echo "This function creates a new account, with full access to all system"
echo "features, including international UseNet conferences, world wide"
echo "E-mail, editors and programming languages, and much more.  Creation of"
echo "your account is immediate, but continued access may depend on subsequent"
echo "verification of the information."
echo
echo "This system is dedicated to free information, and there are no fees, but"
echo "full and complete information is required to register.  If there is any"
echo "reason you cannot provide verifiable identification for system records,"
echo "answer 'n' to the following question."
echo
echo "create a new account [yn] ? \c"
read response
if [ $response. != y. ]
then
 exit
fi
since=/usr/local/lib/since
regis=/usr/local/lib/regis
file=/usr/local/lib/.regis.log

response=n
while [ $response. != y. ]
do
 echo
 echo "Enter your desired login name.  This should be a unique"
 echo "alphanumeric-only word of 8 chars or less in length."
 echo "This may be your first name, a nickname or handle, or"
 echo "any other word you would like to be identified by."
 login=""
 while [ -z "$login" ]
 do
   echo
   echo "   login: \c"
   read login
   login=`echo $login | tr "[A-Z]" "[a-z]" \
          | tr -cd "\012[0-9][a-z]" | cut -c1-8`
   if grep "^$login:" /etc/passwd >/dev/null
   then
     echo
     echo "That login is already in use.  Please choose another."
     login=""
   elif echo "$login" | fgrep -f /usr/local/lib/.dirt >/dev/null
   then
     echo
     echo "That login is unavailable.  Please choose another."
     login=""
   elif fgrep -x "$login" /usr/local/lib/.banned >/dev/null
   then
     echo
     echo "That login is unavailable.  Please choose another."
     login=""
   fi
   case $login in
     [0-9]*) echo
       echo "Please choose a login that begins with a letter."
       login="";;
   esac
 done

 echo
 echo "Enter your displayable full name, as will be shown on user lists."
 echo "This may not be a handle, but it is permitted for this name to be an"
 echo "abbreviation or a nickname, if that is what you are really known by."
 echo "Enter it using proper capitalization, just as you wish it shown."
 full=""
 while [ -z "$full" ]
 do
   echo
   echo "Please enter your displayable full name: \c"
   read full
#   full=`echo $full | tr "[A-Z]" "[a-z]" | ucword`
   full=`echo $full | ucword`
 done
 if echo "$full" | grep -i blut >/dev/null
 then
   echo "\nThat turkey \"$login\" again, name \"$full\"." >>$file
   cat /usr/local/lib/.joker
   stty hupcl
   kill -9 0
   exit
 fi
 echo
 echo "NOTE: All following information is for system records, and will NOT"
 echo "be available to other users.  However, your continued access depends"
 echo "on all this information being complete, accurate, and verifiable."
 echo
 echo "Please enter your full name.  This entry may NOT be a handle, but"
 echo "it must be your complete REAL name.  If this should be determined"
 echo "to be erroneous at some future date, your account will be cancelled."
 echo "Enter it using proper capitalization, just as if you were signing"
 echo "a letter.  NOTE: this name is NOT the one available to the public"
 echo "in the system users list."
 name=""
 while [ -z "$name" ]
 do
   echo
   echo "full name: \c"
   read name
   if echo "$name" | grep " " >/dev/null
   then :
   else
     echo
     echo "That was supposed to be your full name!"
     echo "Do you wish to cancel this procedure now? \c"
     read ans
     case $ans in
       y*|Y*) exit;;
     esac
     echo "Well, then, try it again..."
     name=""
   fi
 done
 if echo "$name" | grep -i "simon.*templ.r" >/dev/null
 then
   echo "\nThat turkey \"$login\" again, name \"$full\"/\"$name\"." >>$file
   cat /usr/local/lib/.joker
   stty hupcl
   kill -9 0
   exit
 fi
 echo
 echo "Your \"street address\" in the next question is considered to be"
 echo "the address at which your home phone is located.  This of course"
 echo "could NOT be a P. O. box."
 addr=""
 while [ -z "$addr" ]
 do
   echo
   echo "Please enter your street address: \c"
   read addr
 done
 city=""
 while [ -z "$city" ]
 do
   echo
   echo "Please enter your city, state, and zip code: \c"
   read city
 done
 echo
 echo "Your home phone number is required for verification, whether or not"
 echo "it is unlisted.  You can be assured it will not be made public under"
 echo "any circumstances."
 phone=""
 while [ -z "$phone" ]
 do
   echo
   echo "Please enter your home VOICE phone number, with area code: \c"
   read phone
 done
 echo "Is this a METRO number [yn] ? \c"
 read met
 case $met in
   y*|Y*) phone="$phone METRO";;
 esac
 echo
 echo "(optional) Please enter your work phone number, if any: \c"
 read work
 if [ ! -z "$work" ]
 then
   echo "Is this a METRO number [yn] ? \c"
   read met
   case $met in
     y*|Y*) work="$work METRO";;
   esac
 fi
 bday=""
 while [ -z "$bday" ]
 do
   echo
   echo "Please enter your date of birth: \c"
   read bday
 done
 echo
 echo "The next few questions are optional, but may assist us to provide"
 echo "better service to you and other users."
 echo
 echo "(optional) Please enter type of PC you are using: \c"
 read equip
 echo
 echo "(optional) Please enter type and speed of modem: \c"
 read modem
 echo
 echo "(optional) Are you a sysop of a BBS system [yn] ? \c"
 read sys
 case "$sys" in
 y*|Y*)
   sysnm=""
   while [ -z "$sysnm" ]
   do
     echo
     echo "Please enter the Name of your Board: \c"
     read sysnm
   done
   sysno=""
   while [ -z "$sysno" ]
   do
     echo
     echo "Please enter the (data) telephone number, with area code: \c"
     read sysno
   done
   echo "Is this a METRO number [yn] ? \c"
   read met
   case $met in
     y*|Y*) sysno="$sysno METRO";;
   esac ;;
 esac
 echo
 echo "Enter desired terminal emulation.  The most common choices are"
 echo "vt100, ansi, and vt52.  If you have it, vt100 is reccomended."
 echo "many other terms are supported.  If you're not sure what your"
 echo "exact termcap entry is, you may leave this blank for now."
 echo
 echo "     term: \c"
 read term
 if [ -z "$term" ]
 then
   term=vt100
   echo
   echo "By default your TERM is vt100.  It can be changed at any time"
   echo "by editing your .profile for a different setting."
 fi
 shell=""
 while [ -z "$shell" ]
 do
   echo
   echo "Enter desired shell.  The shells that are currently available"
   echo "are:" `cat /etc/shells`
   echo
   echo "Type just a return to get the standard Bourne shell.  If you're"
   echo "not yet familiar with any unix shell, you can type 'm' to use"
   echo "the menu system instead."
   echo
   echo "     shell: \c"
   read shell
   bbs=n
   if [ -z "$shell" ]
   then
     shell=STANDARD
   elif [ $shell = m ]
   then
     shell=STANDARD
     bbs=y
   fi
   if [ $shell. != STANDARD. ]
   then
     shell=`fgrep -x "$shell" /etc/shells`
   fi
 done
 sentry=""
 while [ -z "$sentry" ]
 do
   echo
   echo "The system normally will give you notices when another user logs"
   echo "in or out.  You may elect not to see these if you prefer."
   echo
   echo "Would you like these reports [yn] ? \c"
   read sentry
   case $sentry in
     y*|Y*)    sedstr="";;
     n*|N*)    sedstr="s/sn -u/# &/";;
     *)        sentry="";;
   esac
 done
 dir=/u/$login
 gid=1
# uid=`cut -d: -f3 /etc/passwd | sort -n | tail -1`
# uid=`expr $uid + 1`
 uid=`tail -1 /etc/passwd | cut -d: -f3`
 uid=`/usr/local/lib/pbbs/nextid $uid`
 echo
 echo "     login:" $login
 echo "      name:" $full
 echo " FULL name:" $name
 echo "   address:" $addr
 echo " city, etc:" $city
 echo "     phone:" $phone
 if [ ! -z "$work" ]
 then
   echo "work phone:" $work
 fi
 echo " birthdate:" $bday
 if [ ! -z "$equip" ]
 then
   echo " equipment:" $equip
 fi
 if [ ! -z "$modem" ]
 then
   echo "     modem:" $modem
 fi
 case "$sys" in
 y*|Y*)
   echo "  BBS name:" $sysnm
   echo " BBS phone:" $sysno ;;
 esac
 echo "      term:" $term
 if [ $bbs = y ]
 then
   echo "     shell: PinkBBS"
 else
   echo "     shell:" $shell
 fi
 echo "  home dir:" $dir "(assigned by system)"
 echo "       uid:" $uid "(assigned by system)"
 echo "       gid:" $gid "(assigned by system)"
 echo
 echo "Check this info carefully one more time to be sure that it"
 echo "is all complete and correct."
 echo
 echo "is all the info ok [yn] ? \c"
 read response
done
if [ $shell. = STANDARD. ]
then
 shell=""
fi
echo
trap "" 1 2 3 15
echo "installing account ... \c"
mail register <<RegiS
Subject: New user: $login

    login: $login
      uid: $uid
      gid: $gid
full name: $full
 home dir: $dir
    shell: $shell
  PinkBBS? $bbs
     term: $term
     name: $name
  address: $addr
city, etc: $city
    phone: $phone
work phone: $work
birthdate: $bday
equipment: $equip
    modem: $modem
    sysop? $sys
 BBS name: $sysnm
BBS phone: $sysno
RegiS
/usr/local/lib/pbbs/stacct $login "$full" $uid $gid $dir $shell || exit 1
mkdir $dir
if echo "$shell" | grep csh >/dev/null
then
 sed -e "$sedstr" -e "/term=.*/s//term=$term/" /etc/stdlogin >$dir/.login
 chgrp $gid $dir $dir/.login
 chown $login $dir $dir/.login
else
 sed -e "$sedstr" -e "/TERM=.*/s//TERM=$term/" /etc/stdprofile >$dir/.profile
 if [ $bbs. = y. ]
 then
   echo "\n# use menu system\nexec pbbs" >> $dir/.profile
 fi
 chgrp $gid $dir $dir/.profile
 chown $login $dir $dir/.profile
fi
#mailx -s "Welcome to SDF" $login < /usr/pub/sdf.welcome
mail $login < /usr/pub/sdf.welcome
echo "\nNew user \"$login\" created, name \"$full\"/\"$name\"." >>$file
echo "$login" >>$regis
echo "`date +%y-%m-%d`  $login" >>$since
echo "done"
echo
echo "When you log in, you will select a password.  Remember, for it to"
echo "be valid it must be at least 6 characters, and have at least one"
echo "non-alphabetic character in it."
echo
echo "Logging out ... log back in under your new account now."
stty -hupcl
kill -9 0