Skip to content
Snippets Groups Projects
Commit d842efb0 authored by brinn's avatar brinn
Browse files

fix: make datamover.start work on Linux, Solaris and Darwin (should also work...

fix: make datamover.start work on Linux, Solaris and Darwin (should also work on other BSD systems, but hasn't been tested)

SVN: 1641
parent c14700f6
No related branches found
No related tags found
No related merge requests found
#! /bin/sh #! /bin/sh
awkBin()
{
# We need a awk that accepts variable assignments with '-v'
case `uname -s` in
"SunOS")
echo "nawk"
return
;;
esac
# default
echo "awk"
}
isPIDRunning()
{
if [ "$1" = "" ]; then
return 0
fi
# This will have a return value of 0 on BSDish systems
isBSD="`ps aux > /dev/null 2>&1; echo $?`"
AWK=`awkBin`
if [ "$isBSD" = "0" ]; then
if [ "`ps aux | $AWK -v PID=$1 '{if ($2==PID) {print "FOUND"}}'`" = "FOUND" ]; then
return 0
else
return 1
fi
else
if [ "`ps -ef | $AWK -v PID=$1 '{if ($2==PID) {print "FOUND"}}'`" = "FOUND" ]; then
return 0
else
return 1
fi
fi
}
if [ -f datamover.pid ]; then if [ -f datamover.pid ]; then
PID=`cat datamover.pid` PID=`cat datamover.pid`
if [ "$PID" != "" ]; then isPIDRunning $PID
if [ `ps -ef |grep $PID |grep -v grep|wc -l` = 1 ] ; then if [ $? -eq 0 ]; then
kill $PID kill $PID
echo "Already running - killing PID $PID and restarting" echo "Already running - killing PID $PID and restarting"
fi
fi fi
rm datamover.pid rm datamover.pid
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment