From: Bob Ribbeck (bribbeck@exucom.com)
Date: 12/28/92


From: bribbeck@exucom.com (Bob Ribbeck)
Subject: forget adduser use a script
Date: 28 Dec 1992 07:08:10 GMT


  Forget adduser use your own script similar to this. This one assumes
all users to add are group 6 and get /bin/sh as their startup shell.
it searches /etc/passwd to see if the logname is already used and counts
the group 6 users for the next user# assuming the first user was 100.

l='list'
pw='/etc/passwd'
old='/home/user1/'

echo -n Enter logname:" "
read ln
if grep -s ^$ln $pw
then
  echo $ln already exists
  exit
fi
new='/home/'$ln
m='/usr/spool/mail/'$ln

echo -n $ln:: > $l
awk -F: '{if ($4 == "6") count++}
          END {print count+=100 >> "list" }' $pw
echo -n Enter real name:" "
read rn
echo -n :6:$rn:$new:/bin/sh >> $l
echo Jx[Bdd:wq > xx
vi $l < xx > /dev/null
cat $l
echo -n If ok press enter if not press ^c
read n
cat $l >> $pw
rm $l xx

mkdir $new
chown $ln $new
chgrp users $new
cp $old.profile $new
cp $old.bash_history $new
cd $new
chown $ln .*
chgrp users .*
cp /dev/null $m
chown $ln $m
chgrp mail $m
chmod 662 $m