#!/bin/sh
LD_LIBRARY_PATH=/usr/local/gwa/lib:/usr/local/lib:/etc/lib:/usr/lib:/usr/ucblib
export LD_LIBRARY_PATH
if [ "$1" = "-s" ] ; then
SETONLY=1
shift
fi
PORT=$1
if [ -z "$PORT" ]; then
PORT=2000
fi
OFFSET=0
PATH=/usr/local/gwa/bin:.:$PATH
kill `cat /var/run/pdd.pid 2> /dev/null` 2> /dev/null
kill -9 `cat /var/run/pdd.pid 2> /dev/null` 2> /dev/null
kill `ps -e | grep pdd | grep -v setpdd | grep -v grep | awk '{print $1;}'` 2> /dev/null
kill -9 `ps -e | grep pdd | grep -v setpdd | grep -v grep | awk '{print $1;}'` 2> /dev/null
while /bin/true ; do
# clear
TRY=`echo $PORT + $OFFSET | bc`
echo Trying $TRY...
setconf pdd system port $TRY
if [ -n "$SETONLY" ]; then
exit
fi
if /usr/local/gwa/bin/pdd ; then
echo ""
echo Restarting httpd
kill `cat /usr/local/apache/logs/httpd.pid 2> /dev/null` 2> /dev/null
sleep 2
kill -9 `ps -e | grep httpd | grep -v grep | awk '{print $1;}'` 2> /dev/null
sleep 2
/etc/init.d/httpd start 2> /dev/null
/etc/rc.d/init.d/httpd start 2> /dev/null
#for disp in sdad sdud ; do
# echo Restarting $disp
# kill `cat /var/run/$disp 2> /dev/null` 2> /dev/null
# sleep 2
# kill -9 `ps -e | grep $disp | grep -v grep | awk '{print $1;}'` 2> /dev/null
# sleep 2
# #for dir in /etc/init.d /etc/rc.d/init.d ; do
# # if [ -x "$dir/$disp" ] ; then
# # $dir/$disp start
# # fi
# #done
#done
#exit
fi
OFFSET=`echo $OFFSET + 1 | bc`
done