#!/sbin/sh
# /usr/local/sbin/pwcheck
PS='/usr/bin/ps'
GREP='/usr/local/bin/grep'
AWK='/usr/local/bin/awk'
ALL_PID=`$PS -aef ¦ $GREP "/usr/local/sbin/pwcheck" ¦ $GREP -v grep ¦ $AWK '{print $2}'`
PID=`echo $ALL_PID ¦ $AWK '{print $1}'`
case "$1" in
'start')
if [ -f /usr/local/sbin/pwcheck ]; then
if [ $PID ]; then
echo "pwcheck has started"
else
/usr/local/sbin/pwcheck
echo "Starting: pwcheck"
fi
fi
;;
'stop')
if [ $PID ]; then
while [ $PID ]
do
kill -9 $PID
ALL_PID=`$PS -aef ¦ $GREP /usr/local/sbin/pwcheck ¦ $GREP -v grep ¦ $AWK '{print $2}'`
PID=`echo $ALL_PID ¦ $AWK '{print $1}'`
done
echo "Stopping: pwcheck"
else
echo "pwcheck has NotRnning"
fi
;;
'restart')
$0 stop
sleep 3
$0 start
;;
'status')
if [ $PID ]; then
echo "pwcheck starts"
else
echo "pwcheck has NotRnning"
fi
;;
*)
echo "Usage: $0 { start ¦ stop ¦ restart ¦ status }"
exit 1
;;
esac
exit 0 |