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