WANTED: Script for add users

Brian Fenske fenske at iftccu.ca.boeing.com
Tue Jun 5 04:16:47 AEST 1990


Here is what I use.  Disregard references to Elm, our mailer, if you don't
use it.

--------------------------------------------------
#/bin/csh -f
#
# Current working directory MUST be /users to invoke!!!
# Invoke this with:
#        newacc username group
#
if ( $#argv < 2 ) then
	echo "Usage: newacc [login name] [group]"
	exit 1
endif
grep -w ^$1 /etc/passwd > /dev/null
if ( $status == 0 ) then
	echo " "
	echo "An account with this name is already on the system\!"
	echo " "
	exit 0
endif
vipw
vi /etc/group
vi /usr/lib/aliases
newaliases
mkdir $1
chmod 755 $1
chown $1 $1
chgrp $2 $1
cd $1
cp ../.cshrc .
cp ../.login .
cp ../.elmrc .
touch .msgsrc
mkdir mail
touch mail/logfile
chown $1 .cshrc
chown $1 .login
chown $1 .elmrc
chown $1 .msgsrc
chown $1 mail/logfile
chown $1 mail
chmod 644 .cshrc
chmod 644 .login
chmod 644 .elmrc
chmod 644 .msgsrc
chmod 600 mail/logfile
chmod 755 mail
vi .elmrc
cd ..
passwd $1
--------------------------------------------------

I also have a script to remove a user:

--------------------------------------------------
#/bin/csh -f
# Invoke this with:
#        rmacc username
if ( $#argv < 1 ) then
	echo "Usage: rmacc [login name]"
	exit 1
endif
echo ""
echo -n "Do you really want to remove $1?  Answer 'yes' or 'no' > "
set RSP = $< 
if ($RSP == "yes") then
	echo ""
	echo "removing files..."
	echo ""
	rm /usr/spool/mail/$1
	rm -rf ~$1
	vipw
	vi /etc/group
	vi /usr/lib/aliases
	newaliases
	echo ""
	echo ""
	echo ""
	echo "  $1 removed from system."
	echo ""
else
	exit 0
endif
--------------------------------------------------

--
Brian Fenske                     Manufacturing Research & Development
Boeing Commercial Airplanes      747-400 Integrated Functional Test System
P.O. Box 3707,  M/S 0P-37        (206) 342-5784
Seattle, WA  98124               ...uunet!bcstec!iftccu!fenske



More information about the Comp.unix.questions mailing list