2000-12-22 05:00:29 +03:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# /u/sonmi/bin/qaclean
|
|
|
|
#
|
|
|
|
# is supposed to clean up after a "hanging" QA
|
|
|
|
#
|
|
|
|
# 1) see if there is a lockfile
|
|
|
|
# if yes:
|
|
|
|
# 1a) kill the process of the lockfile and if possible it's children
|
|
|
|
# 1b) rm the lockfile
|
|
|
|
# 2) kill selfservers
|
|
|
|
# 3) clean up old tmp files
|
|
|
|
#
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
if [ -z "$TMP" ]
|
|
|
|
then
|
|
|
|
if [ -z "$TEMP" ]
|
|
|
|
then
|
|
|
|
TMP="/tmp"
|
|
|
|
else
|
|
|
|
TMP=$TEMP
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ ! -w "$TMP" ]
|
|
|
|
then
|
|
|
|
echo "Can't write to tmp directory $TMP - exiting"
|
|
|
|
echo "Can't write to tmp directory $TMP - exiting" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
########################### Ps #########################################
|
|
|
|
# platform specific ps
|
|
|
|
########################################################################
|
|
|
|
Ps()
|
|
|
|
{
|
|
|
|
if [ `uname -s` = "SunOS" ]
|
|
|
|
then
|
|
|
|
/usr/5bin/ps -e
|
|
|
|
else
|
|
|
|
ps -e
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
Kill()
|
|
|
|
{
|
2000-12-22 06:02:01 +03:00
|
|
|
if [ "$1" = "$$" ]
|
|
|
|
then
|
|
|
|
return
|
|
|
|
fi
|
2000-12-22 05:00:29 +03:00
|
|
|
echo "Killing PID $1"
|
|
|
|
kill $1
|
|
|
|
sleep 1
|
|
|
|
kill -9 $1 2>/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
########################### kill_by_name ################################
|
|
|
|
# like killall, only without permissionproblems, kills the process whose
|
|
|
|
# name is given as parameter
|
|
|
|
########################################################################
|
|
|
|
kill_by_name()
|
|
|
|
{
|
|
|
|
echo "Killing all $1"
|
2000-12-22 05:31:56 +03:00
|
|
|
|
2000-12-22 05:00:29 +03:00
|
|
|
for PID in `Ps | grep "$1" | grep -v grep | \
|
2000-12-22 05:31:56 +03:00
|
|
|
sed -e "s/^[ ]*//g" -e "s/[ ].*//"`
|
2000-12-22 05:00:29 +03:00
|
|
|
do
|
|
|
|
Kill $PID
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
kill_the_rest()
|
|
|
|
{
|
|
|
|
i=0
|
|
|
|
while [ $i -lt $1 ]
|
|
|
|
do
|
2000-12-22 05:31:56 +03:00
|
|
|
kill_by_name nssqa
|
2000-12-22 05:00:29 +03:00
|
|
|
kill_by_name selfserv
|
|
|
|
kill_by_name strsclnt
|
|
|
|
kill_by_name all.sh
|
|
|
|
kill_by_name sdr.sh
|
|
|
|
kill_by_name ssl.sh
|
|
|
|
kill_by_name smime.sh
|
|
|
|
i=`expr $i + 1`
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2000-12-22 05:31:56 +03:00
|
|
|
nt_warning()
|
|
|
|
{
|
|
|
|
os_name=`uname -s`
|
|
|
|
case $os_name in
|
|
|
|
CYGWIN*|WIN*|Win*)
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo "Another Windows problem... If you have not already done so"
|
|
|
|
echo "after this script completes, please reboot, and log in as"
|
|
|
|
echo "user svbld again"
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2000-12-22 06:02:01 +03:00
|
|
|
nt_warning
|
2000-12-22 05:00:29 +03:00
|
|
|
case $1 in
|
|
|
|
?*)
|
|
|
|
rsh $1 '/u/sonmi/bin/qaclean'
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
uname -a
|
2000-12-22 05:31:56 +03:00
|
|
|
echo
|
2000-12-22 05:00:29 +03:00
|
|
|
|
|
|
|
if [ -f ${TMP}/nssqa.* ]
|
|
|
|
then
|
|
|
|
echo "nssqa seems to be running ${TMP}/nssqa.*"
|
|
|
|
#cat ${TMP}/nssqa.*
|
|
|
|
NSSQA_PID=`ls ${TMP}/nssqa.* | sed -e 's/[^.]*\.//'`
|
|
|
|
Kill $NSSQA_PID
|
|
|
|
rm ${TMP}/nssqa.*
|
|
|
|
fi
|
|
|
|
|
|
|
|
kill_the_rest 3
|
|
|
|
rm ${TMP}/nsstmp.* 2>/dev/null
|
|
|
|
rm ${TMP}/certutilout.* 2>/dev/null
|
2000-12-22 05:31:56 +03:00
|
|
|
nt_warning
|