nss: import at 3.0.1 beta 1
[mozilla-nss.git] / security / nss / tests / qaclean
blob14c71f390ef5e212c553228bc8fee2164c6f56e2
1 #! /bin/sh
3 ########################################################################
5 # /u/sonmi/bin/qaclean
7 # is supposed to clean up after a "hanging" QA
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
16 ########################################################################
18 if [ -z "$TMP" ]
19 then
20 if [ -z "$TEMP" ]
21 then
22 TMP="/tmp"
23 else
24 TMP=$TEMP
27 if [ ! -w "$TMP" ]
28 then
29 echo "Can't write to tmp directory $TMP - exiting"
30 echo "Can't write to tmp directory $TMP - exiting" >&2
31 exit 1
34 ########################### Ps #########################################
35 # platform specific ps
36 ########################################################################
37 Ps()
39 if [ `uname -s` = "SunOS" ]
40 then
41 /usr/5bin/ps -e
42 else
43 ps -e
47 Kill()
49 if [ "$1" = "$$" ]
50 then
51 return
53 echo "Killing PID $1"
54 kill $1
55 sleep 1
56 kill -9 $1 2>/dev/null
59 ########################### kill_by_name ################################
60 # like killall, only without permissionproblems, kills the process whose
61 # name is given as parameter
62 ########################################################################
63 kill_by_name()
65 echo "Killing all $1"
67 for PID in `Ps | grep "$1" | grep -v grep | \
68 sed -e "s/^[ ]*//g" -e "s/[ ].*//"`
70 Kill $PID
71 done
74 kill_the_rest()
76 i=0
77 while [ $i -lt $1 ]
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`
87 done
90 nt_warning()
92 os_name=`uname -s`
93 case $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
105 esac
108 nt_warning
109 case $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
116 echo $w
117 ping $w && rsh $w '/u/sonmi/bin/qaclean'
118 done
122 rsh $1 '/u/sonmi/bin/qaclean'
123 exit
125 esac
127 uname -a
128 echo
130 if [ -f ${TMP}/nssqa.* ]
131 then
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.*
139 kill_the_rest 3
140 ls -l ${TMP}/nsstmp.*
141 rm ${TMP}/nsstmp.* 2>/dev/null
142 rm ${TMP}/certutilout.* 2>/dev/null
143 rm ${TMP}/Pk12*
144 nt_warning