P#I'm not sure how to shar shell scripts, so I just arbitrarily
P#put a capital letter in column 1.  sed should snarf it fine.
P#!/bin/sh
P#adduser shell script ... bypasses most of the
P# agony the sysadm (SysVr2) route makes you go through
P#jhn 06jan87
Pcase `uname` in
P	3b2b)
P		echo "puttem where? 2,3,or 4 [default is /usr] \c"
P		read blonk
P		case $blonk in
P			2) scrod=2;;
P			3) scrod=3;;
P			4) scrod=4;;
P			"") scrod="";;
P			*) echo "valid responses are <cr>, 2, 3, or 4.  Bye...";
P			   exit;;
P		esac ;;
P	3b2a) scrod="";;
Pesac #end case uname
Pscrod=usr${scrod}
Pecho "putting them in /$scrod
P	please wait ... looking for next avail userno" 
P
Pgroup=100
Pnextuser=`/usr/bin/awk -F: '$3+0>num+0 {num=$3+0}
PEND {print 1+num}' /etc/passwd `
P#nextuser=`expr $nextuser + 1`
Pecho next available userno is $nextuser
P
Pwhile : ; do
Pecho "enter fullname \c"
Pread fullname
Pcase $fullname in
P	"") echo "null user fullname not allowed"; exit 1;;
Pesac
P
Pecho "enter loginname \c"
Pread login
Pcase $login in
P	"") echo "null user name not allowed"; exit 1;;
Pesac
Pecho "enter usernumber [$nextuser] \c"
Pread user
Pcase $user in
P	"") user=$nextuser;echo "using $user";;
Pesac
Pnextuser=`expr $user + 1`
Ploop=true
Pwhile :
Pdo
P	echo "enter group (? for cat /etc/group) [$group] \c"
P	read xroup
P	case $xroup in
P		\?) cat /etc/group;;
P		"") break;;
P		*) group=$xroup;break;;
P	esac
Pdone
Pcase $group in
P	"") echo null group not allowed ... bye; exit 1;;
Pesac
P
P/usr/bin/awk -F: '$1=='\"$login\"' || $3=='\"$user\"' {print}' /etc/passwd\
P	>/tmp/au$$
Palready=""
Pif test -s /tmp/au$$
Pthen
P	/bin/cat /tmp/au$$
P	echo "login=$login or user=$user in use ..."
P	rm -f /tmp/au$$
P	already=1
Pfi
Pif test -d /${scrod}/$login
Pthen
P	echo "/${scrod}/$login already exists ... !"
P	rm -f /tmp/au$$
P	already=1
Pfi
P
P
Pcase $already in
P	"")
P	/bin/mkdir /${scrod}/$login
P	echo "$login::$user:$group:$fullname:/${scrod}/$login:"
P	echo "ok? [y] \c"
P	read doit
P	case $doit in
P		n) /bin/rmdir /${scrod}/$login; exit 1;;
P	esac
P	/bin/chmod u+w /etc/passwd
P	echo "$login::$user:$group:$fullname:/${scrod}/$login:">>/etc/passwd
P	sync
P	/bin/chmod u+w /etc/passwd
P	tail -2 /etc/passwd
P	/bin/chown $user /${scrod}/$login
P	/bin/chgrp $group /${scrod}/$login
P	/bin/chmod 755 /${scrod}/$login
P	/bin/cp /etc/stdprofile /${scrod}/$login/.profile
P	/bin/chown $user /${scrod}/$login/.profile
P	/bin/chgrp sys /${scrod}/$login/.profile
P	/bin/chmod gu+w /${scrod}/$login/.profile
P	case $umsk in
P		"") echo "enter umask [22]: \c"
P		read umsk
P				case $umsk in
P				"") umsk=22;;
P				esac
P		;;
P	esac
P	echo "umask $umsk">>/${scrod}/$login/.profile
P	echo "menu-shell initially? [n]: \c"
P	read yesno
P	case $yesno in
P		y) echo "/usr/uncw/msh" >> /${scrod}/$login/.profile;;
P		*) echo "menu-shell not selected";;
P	esac
P	echo "give him a password? [y]: \c"
P	read yesno
P	case $yesno in
P		y|"") /bin/passwd $login;;
P		*) echo "no password set for $login";;
P	esac
P	rm -f /tmp/au$$
P	echo "put password aging in effect? [y]: \c"
P	read yesno
P	case $yesno in
P		y|"") /etc/agepw $login;;
P		n) echo password aging not set for $login;;
P	esac
P;;
Pesac	#end of case $already==""
Pcase $god in
P	"") echo "enter godname []: \c"
P	read god;;
P	*) ;;
Pesac
Pcase $god in
P	"") ;;
P	*) echo "$god:$login">>/etc/accesstab
P	;;
Pesac
Pecho '***** done *****
P
P	want to add another user? [y] \c'
Pread domore
Pcase $domore in
P	n) exit;;
Pesac
Pdone
P
