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>

next in thread | raw e-mail | index | archive | help

--tKW2IUtsqtDRztdT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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"

--tKW2IUtsqtDRztdT
Content-Type: application/x-sh
Content-Disposition: attachment; filename="wol-suspend.sh"
Content-Transfer-Encoding: quoted-printable

#!/usr/local/bin/bash=0A=0A# Suspend User and indicate so in .plan=0A=0Auna=
me=3D$1=0A=0A=0A# Sanity Check=0Aif [ -n "$uname" ]; then=0A=0A# Real inSan=
ity =0Aif [ "$uname" !=3D root ]; then=0A=0A# Other Sanity Check=0Aif [ "$u=
name" !=3D admin ]; then=0Aif [ "$uname" !=3D admin1 ]; then=0Aif [ "$uname=
" !=3D admin2 ]; then=0Aif [ "$uname" !=3D admin2b ]; then=0A=0A#	# gtest=
=0A	gtest=3D`groups $uname`=0A	if [ "$gtest" =3D users ]=0A	then=0A=0A#	# G=
et the Dirt=0A	export EDITOR=3D/bin/cat $1=0A=0A	psswdstr=3D`/usr/bin/chsh =
$uname 2> /dev/null | \=0A		/usr/bin/awk '{if (sub(/Password: /,""))print}'=
`=0A=0A# 		# Been There, Done That=0A		if test -z `echo $psswdstr | /usr/bi=
n/grep "*"`=0A		then=0A=0A		testexit=3D`/bin/echo $?`=0A=0A			if [ "$testex=
it" =3D 0 ]; then=0A# 			# Just Do It!=0A=0A			/usr/bin/chsh -p *$psswdstr =
$uname=0A=0A=0A				if [ -f /home/$uname/.plan ]; then=0A				/bin/echo -n "s=
uspended" >> /home/$uname/.plan=0A				else=0A					if [ -d /home/$uname ]; t=
hen=0A					/usr/bin/touch /home/$uname/.plan=0A					/usr/sbin/chown $uname =
/home/$uname/.plan=0A					/bin/echo "suspended" >> /home/$uname/.plan=0A			=
		fi=0A				fi=0A=0A#			# Just Dood It!=0A			fi=0A		else=0A		#echo "Coogan's=
 Bluff (1968)"=0A		echo=0A		echo "$uname is Already suspended"=0A		fi=0A=0A=
#	# gtest=0A	else=0A	:=0A	fi=0A=0Aelse=0Aecho=0A# "A Man For All Seasons (g=
p)"=0Afi=0Aelse=0Aecho=0A# "A Man For All Seasons (p)"=0Afi=0Aelse=0Aecho=
=0A# "A Man For All Seasons (f)"=0Afi=0Aelse=0Aecho "A Man For All Seasons =
(1966)"=0Afi=0Aelse=0Aecho "A Man For All Seasons (1988)"=0Afi=0A=0Aelse=0A=
echo "Il Buono, il brutto, il cattivo (1966)"=0Aecho=0A#echo "Usage: accoun=
t-suspend [user]"=0Afi=0A
--tKW2IUtsqtDRztdT--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isp" in the body of the message




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