diff --git a/MAC/APL/APLCommon/src/swlevel b/MAC/APL/APLCommon/src/swlevel index b48e5395b910ec0e815162edfe504661918d5d57..ee83b7a5b958e5c17e4ad3a2f0a75939ef1c53fa 100755 --- a/MAC/APL/APLCommon/src/swlevel +++ b/MAC/APL/APLCommon/src/swlevel @@ -35,6 +35,9 @@ SBINDIR=$LOFARROOT/sbin LOGDIR=$LOFARROOT/var/log ETCDIR=$LOFARROOT/etc LEVELTABLE=${ETCDIR}/swlevel.conf +# pidof is in /usr/sbin, usually; this is not added to PATH for non-interactive logins +# (in /etc/profile) so explicitly find location of executable pidof now. +PIDOF=`whereis -b pidof | awk '{print $2}'` # Make sure all files are user/group/other writeable (needed for Int. # Stations) @@ -238,7 +241,7 @@ start_prog() fi # Check if program is already running - pidof -x ${prog} 1>/dev/null 2>&1 + $PIDOF -x ${prog} 1>/dev/null 2>&1 if [ $? -ne 0 ]; then curdate=`date +%Y%m%dT%H%M%S` # PVSS needs special treatment @@ -269,7 +272,7 @@ start_prog() fi if [ "$prog" = "TBBDriver" ]; then # Check if RSPDriver is already running; if not, do not start either! - pidof RSPDriver 1>/dev/null 2>&1 + $PIDOF RSPDriver 1>/dev/null 2>&1 if [ $? -ne 0 ]; then echo "RSPDriver not running, so not starting TBBDriver either" exit @@ -321,7 +324,7 @@ stop_prog() fi # get processlist - pidof -x ${prog} 1>/dev/null 2>&1 + $PIDOF -x ${prog} 1>/dev/null 2>&1 if [ $? -ne 0 ]; then return fi @@ -348,7 +351,7 @@ stop_prog() fi # first try normal kill - for pid in `pidof -x ${prog}` + for pid in `$PIDOF -x ${prog}` do echo "Softly killing ${prog}(${pid})" $asroot kill $pid 1>/dev/null 2>&1 @@ -356,7 +359,7 @@ stop_prog() done # when normal kill did not work, kill is with -9 - for pid in `pidof -x ${prog}` + for pid in `$PIDOF -x ${prog}` do echo "Hard killing ${prog}(${pid})" $asroot kill -9 $pid 1>/dev/null 2>&1 @@ -364,7 +367,7 @@ stop_prog() done # if user0 or lofarsys, try normal kill as root - for pid in `pidof -x ${prog}` + for pid in `$PIDOF -x ${prog}` do if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then sudo kill $pid 1>/dev/null 2>&1 @@ -373,7 +376,7 @@ stop_prog() done # if user0 or lofarsys, try hard kill as root - for pid in `pidof -x ${prog}` + for pid in `$PIDOF -x ${prog}` do if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then sudo kill -9 $pid 1>/dev/null 2>&1 @@ -382,7 +385,7 @@ stop_prog() done # if still alive, write a message - for pid in `pidof -x ${prog}` + for pid in `$PIDOF -x ${prog}` do echo -n "Could not kill ${prog}(${pid}); " if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then @@ -442,9 +445,9 @@ status_prog() # find out the processID of the possibly (running) process obsid=() pid_user=() - pidof -x ${prog} 1>/dev/null 2>&1 + $PIDOF -x ${prog} 1>/dev/null 2>&1 if [ $? -eq 0 ]; then - pid=( `pidof -x ${prog}` ) + pid=( `$PIDOF -x ${prog}` ) i=0 for apid in ${pid[@]} do @@ -522,7 +525,7 @@ goto_level() # set rcumode to 0 (power save) when entering level 1 if [ ${newlevel} -le 1 ]; then if [ ${curlevel} -ge 2 ]; then - pidof RSPDriver 1>/dev/null 2>&1 + $PIDOF RSPDriver 1>/dev/null 2>&1 if [ $? -eq 0 ]; then status=`( rspctl --version | grep "0.0" ) >& /dev/null; echo $?` if [ $status == 1 ]; then