#!/bin/sh # # patronus # # Dispel ghost logins that suck the joy out of your active terminal session # # Copyright (C) 2007 Richard Bullington-McGuire # Many thanks (and aplologies) to J.K. Rowling # # DISCLAIMER # This is a parody of J.K. Rowling's Harry Potter novels. # Lawyers: please don't sue this poor house-elf who is only trying to help. # # LICENSE # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Release History: # # 1.0 (September 6, 2007) # First public release retval=1 MAGICAL_CREATURES=`mktemp -t patronus.XXXXXXXXXX` && { FLOO_NETWORK=`mktemp -t patronus.XXXXXXXXXX` && { echo "Lumos!" echo "" ps x > $MAGICAL_CREATURES FLOO_EXITS=`egrep " *$$" $MAGICAL_CREATURES | \ awk '{print $2}'` awk '!/ PID/{print $2}' < $MAGICAL_CREATURES | \ sort -u | egrep -v "^\?|$FLOO_EXITS" > $FLOO_NETWORK DEMENTORS=`cat $FLOO_NETWORK` if [ -z "$DEMENTORS" ] ; then echo "No dementors spotted nearby." retval=0 else DEMENTOR_KISSES=`grep -f $FLOO_NETWORK < $MAGICAL_CREATURES | \ awk '{print $1}'` DEMENTOR_DESCRIPTION=`ps u $DEMENTOR_KISSES` cat << EOT Traversing floo network at $FLOO_EXITS, dementors spotted at: $DEMENTORS Specialis Revelio! Dementors found: $DEMENTOR_DESCRIPTION EXPECTO PATRONUM! EOT kill -HUP $DEMENTOR_KISSES 2>/dev/null retval=$? fi rm -f $FLOO_NETWORK } rm -f $MAGICAL_CREATURES } exit $retval