michael@0: #! /bin/sh michael@0: michael@0: ######################################################################## michael@0: # michael@0: # /u/sonmi/bin/qaclean michael@0: # michael@0: # is supposed to clean up after a "hanging" QA michael@0: # michael@0: # 1) see if there is a lockfile michael@0: # if yes: michael@0: # 1a) kill the process of the lockfile and if possible it's children michael@0: # 1b) rm the lockfile michael@0: # 2) kill selfservers michael@0: # 3) clean up old tmp files michael@0: # michael@0: ######################################################################## michael@0: michael@0: if [ -z "$TMP" ] michael@0: then michael@0: if [ -z "$TEMP" ] michael@0: then michael@0: TMP="/tmp" michael@0: else michael@0: TMP=$TEMP michael@0: fi michael@0: fi michael@0: if [ ! -w "$TMP" ] michael@0: then michael@0: echo "Can't write to tmp directory $TMP - exiting" michael@0: echo "Can't write to tmp directory $TMP - exiting" >&2 michael@0: exit 1 michael@0: fi michael@0: michael@0: ########################### Ps ######################################### michael@0: # platform specific ps michael@0: ######################################################################## michael@0: Ps() michael@0: { michael@0: if [ `uname -s` = "SunOS" ] michael@0: then michael@0: /usr/5bin/ps -e michael@0: else michael@0: ps -e michael@0: fi michael@0: } michael@0: michael@0: Kill() michael@0: { michael@0: if [ "$1" = "$$" ] michael@0: then michael@0: return michael@0: fi michael@0: echo "Killing PID $1" michael@0: kill $1 michael@0: sleep 1 michael@0: kill -9 $1 2>/dev/null michael@0: } michael@0: michael@0: ########################### kill_by_name ################################ michael@0: # like killall, only without permissionproblems, kills the process whose michael@0: # name is given as parameter michael@0: ######################################################################## michael@0: kill_by_name() michael@0: { michael@0: echo "Killing all $1" michael@0: michael@0: for PID in `Ps | grep "$1" | grep -v grep | \ michael@0: sed -e "s/^[ ]*//g" -e "s/[ ].*//"` michael@0: do michael@0: Kill $PID michael@0: done michael@0: } michael@0: michael@0: kill_the_rest() michael@0: { michael@0: i=0 michael@0: while [ $i -lt $1 ] michael@0: do michael@0: kill_by_name nssqa michael@0: kill_by_name selfserv michael@0: kill_by_name strsclnt michael@0: kill_by_name all.sh michael@0: kill_by_name sdr.sh michael@0: kill_by_name ssl.sh michael@0: kill_by_name smime.sh michael@0: i=`expr $i + 1` michael@0: done michael@0: } michael@0: michael@0: nt_warning() michael@0: { michael@0: os_name=`uname -s` michael@0: case $os_name in michael@0: CYGWIN*|WIN*|Win*) michael@0: echo michael@0: echo michael@0: echo michael@0: echo "Another Windows problem... If you have not already done so" michael@0: echo "after this script completes, please reboot, and log in as" michael@0: echo "user svbld again" michael@0: echo michael@0: echo michael@0: echo michael@0: ;; michael@0: esac michael@0: } michael@0: michael@0: nt_warning michael@0: case $1 in michael@0: -all) michael@0: for w in tommy booboo kentuckyderby galileo shame axilla columbus \ michael@0: smarch charm hp64 biggayal orville kwyjibo hbombaix raven \ michael@0: jordan hornet phaedrus louie box dbldog huey washer dryer \ michael@0: shabadoo trex bummer compaqtor jellyfish sjsu michael@0: do michael@0: echo $w michael@0: ping $w && rsh $w '/u/sonmi/bin/qaclean' michael@0: done michael@0: michael@0: ;; michael@0: ?*) michael@0: rsh $1 '/u/sonmi/bin/qaclean' michael@0: exit michael@0: ;; michael@0: esac michael@0: michael@0: uname -a michael@0: echo michael@0: michael@0: if [ -f ${TMP}/nssqa.* ] michael@0: then michael@0: echo "nssqa seems to be running ${TMP}/nssqa.*" michael@0: #cat ${TMP}/nssqa.* michael@0: NSSQA_PID=`ls ${TMP}/nssqa.* | sed -e 's/[^.]*\.//'` michael@0: Kill $NSSQA_PID michael@0: rm ${TMP}/nssqa.* michael@0: fi michael@0: michael@0: kill_the_rest 3 michael@0: ls -l ${TMP}/nsstmp.* michael@0: rm ${TMP}/nsstmp.* 2>/dev/null michael@0: rm ${TMP}/certutilout.* 2>/dev/null michael@0: rm ${TMP}/Pk12* michael@0: nt_warning