[K12OSN] on second thought...can someone send me /usr/sbin/purge_user?
Nils Breunese
nils at breun.nl
Sun Sep 2 16:20:40 UTC 2007
David Trask wrote:
> See my previous post....actually the file I'm looking for is
> /usr/sbin/purge_user can someone archive it and send it to me? I'm
> looking at modifying it to address an issue I have, but don't have
> access
> to a K12lTSP box at the moment. Thx. Either post, send as
> attachement,
> or whatever. thx.
This is from our K12LTSP 5EL box:
----
#!/bin/bash
KILL=/usr/bin/pkill
CONFIG="/etc/sysconfig/k12ltsp"
# source config file
if [ -f $CONFIG ]
then
. $CONFIG
fi
# define the minimum uid
if [ -f /etc/login.defs ]
then
UID_MIN="`grep UID_MIN /etc/login.defs | awk '{print $2}'`"
fi
if [ ! $UID_MIN ]
then
UID_MIN=500
fi
function usage () {
echo
echo "This script will remove all of a user's processes"
echo
echo "Usage:"
echo " $0 <username> [SANE]"
echo
echo "If \"SANE\" is given as the second arguement, this script
will"
echo "read $CONFIG and will only run if PURGE_PROCESSES=YES"
echo
echo "Also note that this script will refuse to run if the target"
echo "user's uid number is less than $UID_MIN. If you need to
purge a"
echo "system user's processes, please run the $KILL command"
echo "directly"
echo
exit
}
# Sanity Checks
# a username must be specified
if [ ! "$1" ]
then
usage
fi
# do sanity checks?
if [ "$2" = "SANE" ]
then
if [ "$PURGE_PROCESSES" != "YES" ]
then
echo
echo "PURGE_PROCESSES=YES is not set in /etc/sysconfig/
k12ltsp, aborting"
echo
exit
fi
fi
# make sure the pkill command exists
if [ ! -x $KILL ]
then
echo
echo "ERROR: $KILL not found, aborting"
echo
exit
fi
# only work on UIDs greater than 500 (or whatever UID_MIN is set to)
UIDNUMBER=`id -u $1 2> /dev/null`
if [ ! "$UIDNUMBER" ]
then
echo
echo "ERROR: could not determine the user's UID number, aborting"
echo
usage
fi
if [ "$UIDNUMBER" -lt $UID_MIN ]
then
echo
echo "ERROR: user's UID number ($UIDNUMBER) is less than
$UID_MIN, aborting"
echo
usage
fi
# okay, everything checks out. Let's do the dirty work
# first do it nicely
$KILL -u $1
# wait a couple seconds
sleep 2s
# now do it the hard way
$KILL -9 -u $1
----
Nils Breunese.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: Dit deel van het bericht is digitaal ondertekend
URL: <http://listman.redhat.com/archives/k12osn/attachments/20070902/d7b87d65/attachment.sig>
More information about the K12OSN
mailing list