PageRenderTime 20ms CodeModel.GetById 11ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/security/nss/tests/qaclean

http://github.com/zpao/v8monkey
Shell | 144 lines | 108 code | 13 blank | 23 comment | 10 complexity | 7cef1c4d64b1e2779bd0382c45e407e3 MD5 | raw file
  1#! /bin/sh
  2
  3########################################################################
  4#
  5# /u/sonmi/bin/qaclean
  6#
  7# is supposed to clean up after a "hanging" QA
  8#
  9# 1) see if there is a lockfile 
 10#    if yes: 
 11#    1a) kill the process of the lockfile and if possible it's children
 12#    1b) rm the lockfile
 13# 2) kill selfservers
 14# 3) clean up old tmp files
 15#
 16########################################################################
 17
 18if [ -z "$TMP" ]
 19then
 20    if [  -z "$TEMP" ]
 21    then
 22        TMP="/tmp"
 23    else
 24        TMP=$TEMP
 25    fi
 26fi
 27if [ ! -w "$TMP" ]
 28then
 29    echo "Can't write to tmp directory $TMP - exiting"
 30    echo "Can't write to tmp directory $TMP - exiting" >&2
 31    exit 1
 32fi
 33
 34########################### Ps #########################################
 35# platform specific ps
 36########################################################################
 37Ps()
 38{
 39    if [ `uname -s` = "SunOS" ]
 40    then
 41        /usr/5bin/ps -e
 42    else
 43        ps -e
 44    fi
 45}
 46
 47Kill()
 48{
 49    if [ "$1" = "$$" ]
 50    then
 51        return
 52    fi
 53    echo "Killing PID $1"
 54    kill $1
 55    sleep 1
 56    kill -9 $1 2>/dev/null
 57}
 58
 59########################### kill_by_name ################################
 60# like killall, only without permissionproblems, kills the process whose 
 61# name is given as parameter
 62########################################################################
 63kill_by_name()
 64{
 65    echo "Killing all $1"
 66 
 67    for PID in `Ps | grep "$1" | grep -v grep | \
 68        sed -e "s/^[     ]*//g" -e "s/[     ].*//"`
 69    do
 70        Kill $PID
 71    done
 72}
 73
 74kill_the_rest()
 75{
 76i=0
 77while [ $i -lt $1 ]
 78do
 79    kill_by_name nssqa
 80    kill_by_name selfserv
 81    kill_by_name strsclnt
 82    kill_by_name all.sh
 83    kill_by_name sdr.sh
 84    kill_by_name ssl.sh
 85    kill_by_name smime.sh
 86    i=`expr $i + 1`
 87done
 88}
 89
 90nt_warning()
 91{
 92os_name=`uname -s`
 93case $os_name in
 94    CYGWIN*|WIN*|Win*)
 95        echo
 96        echo
 97        echo
 98        echo "Another Windows problem... If you have not already done so"
 99        echo "after this script completes, please reboot, and log in as"
100        echo "user svbld again"
101        echo
102        echo
103        echo
104        ;;
105esac
106}
107
108nt_warning
109case $1 in 
110    -all)
111        for w in tommy booboo kentuckyderby galileo shame axilla columbus \
112                 smarch charm hp64 biggayal orville kwyjibo hbombaix raven \
113                 jordan hornet phaedrus louie box dbldog huey washer dryer \
114                 shabadoo trex bummer compaqtor jellyfish sjsu
115        do
116                echo $w
117                ping $w && rsh $w '/u/sonmi/bin/qaclean'
118        done
119
120        ;;
121    ?*)
122        rsh $1 '/u/sonmi/bin/qaclean'
123        exit
124        ;;
125esac
126
127uname -a
128echo
129
130if [ -f ${TMP}/nssqa.* ]
131then
132    echo "nssqa seems to be running ${TMP}/nssqa.*"
133    #cat ${TMP}/nssqa.*
134    NSSQA_PID=`ls ${TMP}/nssqa.* | sed -e 's/[^.]*\.//'`
135    Kill $NSSQA_PID
136    rm ${TMP}/nssqa.*
137fi
138
139kill_the_rest 3
140ls -l ${TMP}/nsstmp.*
141rm ${TMP}/nsstmp.* 2>/dev/null
142rm ${TMP}/certutilout.* 2>/dev/null
143rm ${TMP}/Pk12*
144nt_warning