Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Mar 2002 17:21:00 +0300
From:      Odhiambo Washington <wash@wananchi.com>
To:        FBSD-ISP <freebsd-isp@freebsd.org>
Subject:   User Maanagement (Bulk Processing)
Message-ID:  <20020320142100.GJ14038@ns2.wananchi.com>

index | next in thread | raw e-mail

[-- Attachment #1 --]
Hello people,

Allow me to ask this because I work for an ISP ;-) Actually I am just seeking help
from shell script gurus. I have a shell script that I use to suspend user accounts
on my FreeBSD box. It works well for single user but there are time like now when
I want to suspend over 400 users for non payment. I have another script that can do
this but again the problem is my scripts are so crude they do not do any sensible
checks <LOL>. My bad.

I am attaching the script - wol-suspend.sh Basically one of you gurus can be able
to modify this script so that it takes a flat file (badusers.txt) which has one
user per line and suspend all of them, yes?? I sincerely hate to do

./wol-suspend.sh userx
./wol-suspend.sh userb

My insistence on this is because our Customer Service Executives will verify the user's
status by doing 

finger userx

and they'll see Plan: Suspended.


Other than this, what tools do pepole use for such tasks? Someone willing to share
what they have??



Thanking you.


-Wash

-- 
Odhiambo Washington  <wash@wananchi.com>    "The box said 'Requires
Wananchi Online Ltd.  www.wananchi.com      Windows 95, NT, or better,'
Tel: 254 2 313985-9   Fax: 254 2 313922     so I installed FreeBSD."   
GSM: 254 72 743 223   GSM: 254 733 744 121  This sig is McQ!  :-)

++
Kleptomaniac, n.:
	A rich thief.
		-- Ambrose Bierce, "The Devil's Dictionary"

[-- Attachment #2 --]
#!/usr/local/bin/bash

# Suspend User and indicate so in .plan

uname=$1


# Sanity Check
if [ -n "$uname" ]; then

# Real inSanity 
if [ "$uname" != root ]; then

# Other Sanity Check
if [ "$uname" != admin ]; then
if [ "$uname" != admin1 ]; then
if [ "$uname" != admin2 ]; then
if [ "$uname" != admin2b ]; then

#	# gtest
	gtest=`groups $uname`
	if [ "$gtest" = users ]
	then

#	# Get the Dirt
	export EDITOR=/bin/cat $1

	psswdstr=`/usr/bin/chsh $uname 2> /dev/null | \
		/usr/bin/awk '{if (sub(/Password: /,""))print}'`

# 		# Been There, Done That
		if test -z `echo $psswdstr | /usr/bin/grep "*"`
		then

		testexit=`/bin/echo $?`

			if [ "$testexit" = 0 ]; then
# 			# Just Do It!

			/usr/bin/chsh -p *$psswdstr $uname


				if [ -f /home/$uname/.plan ]; then
				/bin/echo -n "suspended" >> /home/$uname/.plan
				else
					if [ -d /home/$uname ]; then
					/usr/bin/touch /home/$uname/.plan
					/usr/sbin/chown $uname /home/$uname/.plan
					/bin/echo "suspended" >> /home/$uname/.plan
					fi
				fi

#			# Just Dood It!
			fi
		else
		#echo "Coogan's Bluff (1968)"
		echo
		echo "$uname is Already suspended"
		fi

#	# gtest
	else
	:
	fi

else
echo
# "A Man For All Seasons (gp)"
fi
else
echo
# "A Man For All Seasons (p)"
fi
else
echo
# "A Man For All Seasons (f)"
fi
else
echo "A Man For All Seasons (1966)"
fi
else
echo "A Man For All Seasons (1988)"
fi

else
echo "Il Buono, il brutto, il cattivo (1966)"
echo
#echo "Usage: account-suspend [user]"
fi
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020320142100.GJ14038>