From owner-freebsd-isp Wed Mar 20 6:21:17 2002 Delivered-To: freebsd-isp@freebsd.org Received: from ns2.wananchi.com (ns2.wananchi.com [62.8.64.4]) by hub.freebsd.org (Postfix) with ESMTP id 3EB9C37B400 for ; Wed, 20 Mar 2002 06:21:03 -0800 (PST) Received: from wash by ns2.wananchi.com with local (Exim 3.35 #1 (FreeBSD)) id 16ngxY-000Mmm-00 for ; Wed, 20 Mar 2002 17:21:00 +0300 Date: Wed, 20 Mar 2002 17:21:00 +0300 From: Odhiambo Washington To: FBSD-ISP Subject: User Maanagement (Bulk Processing) Message-ID: <20020320142100.GJ14038@ns2.wananchi.com> Mail-Followup-To: Odhiambo Washington , FBSD-ISP Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="tKW2IUtsqtDRztdT" Content-Disposition: inline User-Agent: Mutt/1.3.25i X-Disclaimer: Any views expressed in this message,where not explicitly attributed otherwise, are mine alone!. X-Fortune: "But officer, I was only trying to gain enough speed so I could coast to the nearest gas station." X-Operating-System: FreeBSD 4.5-STABLE i386 X-Best-Window-Manager: XFCE X-Mailer: Mutt http://www.mutt.org/ X-Designation: Systems Administrator, Wananchi Online Ltd. X-Location: Nairobi, KE, East Africa. X-Uptime: 4:53PM up 11 days, 44 mins, 3 users, load averages: 2.19, 2.29, 2.25 Sender: owner-freebsd-isp@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org --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 . 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 "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