Skip to content
Snippets Groups Projects
Commit 04c76880 authored by Arno Schoenmakers's avatar Arno Schoenmakers
Browse files

Task #11022, #10902: Bugfix for swlevel when used in non-intractive shell

parent 0efb282c
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,9 @@ SBINDIR=$LOFARROOT/sbin ...@@ -35,6 +35,9 @@ SBINDIR=$LOFARROOT/sbin
LOGDIR=$LOFARROOT/var/log LOGDIR=$LOFARROOT/var/log
ETCDIR=$LOFARROOT/etc ETCDIR=$LOFARROOT/etc
LEVELTABLE=${ETCDIR}/swlevel.conf 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. # Make sure all files are user/group/other writeable (needed for Int.
# Stations) # Stations)
...@@ -238,7 +241,7 @@ start_prog() ...@@ -238,7 +241,7 @@ start_prog()
fi fi
# Check if program is already running # 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 if [ $? -ne 0 ]; then
curdate=`date +%Y%m%dT%H%M%S` curdate=`date +%Y%m%dT%H%M%S`
# PVSS needs special treatment # PVSS needs special treatment
...@@ -269,7 +272,7 @@ start_prog() ...@@ -269,7 +272,7 @@ start_prog()
fi fi
if [ "$prog" = "TBBDriver" ]; then if [ "$prog" = "TBBDriver" ]; then
# Check if RSPDriver is already running; if not, do not start either! # 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 if [ $? -ne 0 ]; then
echo "RSPDriver not running, so not starting TBBDriver either" echo "RSPDriver not running, so not starting TBBDriver either"
exit exit
...@@ -321,7 +324,7 @@ stop_prog() ...@@ -321,7 +324,7 @@ stop_prog()
fi fi
# get processlist # get processlist
pidof -x ${prog} 1>/dev/null 2>&1 $PIDOF -x ${prog} 1>/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
return return
fi fi
...@@ -348,7 +351,7 @@ stop_prog() ...@@ -348,7 +351,7 @@ stop_prog()
fi fi
# first try normal kill # first try normal kill
for pid in `pidof -x ${prog}` for pid in `$PIDOF -x ${prog}`
do do
echo "Softly killing ${prog}(${pid})" echo "Softly killing ${prog}(${pid})"
$asroot kill $pid 1>/dev/null 2>&1 $asroot kill $pid 1>/dev/null 2>&1
...@@ -356,7 +359,7 @@ stop_prog() ...@@ -356,7 +359,7 @@ stop_prog()
done done
# when normal kill did not work, kill is with -9 # when normal kill did not work, kill is with -9
for pid in `pidof -x ${prog}` for pid in `$PIDOF -x ${prog}`
do do
echo "Hard killing ${prog}(${pid})" echo "Hard killing ${prog}(${pid})"
$asroot kill -9 $pid 1>/dev/null 2>&1 $asroot kill -9 $pid 1>/dev/null 2>&1
...@@ -364,7 +367,7 @@ stop_prog() ...@@ -364,7 +367,7 @@ stop_prog()
done done
# if user0 or lofarsys, try normal kill as root # if user0 or lofarsys, try normal kill as root
for pid in `pidof -x ${prog}` for pid in `$PIDOF -x ${prog}`
do do
if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then
sudo kill $pid 1>/dev/null 2>&1 sudo kill $pid 1>/dev/null 2>&1
...@@ -373,7 +376,7 @@ stop_prog() ...@@ -373,7 +376,7 @@ stop_prog()
done done
# if user0 or lofarsys, try hard kill as root # if user0 or lofarsys, try hard kill as root
for pid in `pidof -x ${prog}` for pid in `$PIDOF -x ${prog}`
do do
if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then
sudo kill -9 $pid 1>/dev/null 2>&1 sudo kill -9 $pid 1>/dev/null 2>&1
...@@ -382,7 +385,7 @@ stop_prog() ...@@ -382,7 +385,7 @@ stop_prog()
done done
# if still alive, write a message # if still alive, write a message
for pid in `pidof -x ${prog}` for pid in `$PIDOF -x ${prog}`
do do
echo -n "Could not kill ${prog}(${pid}); " echo -n "Could not kill ${prog}(${pid}); "
if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then
...@@ -442,9 +445,9 @@ status_prog() ...@@ -442,9 +445,9 @@ status_prog()
# find out the processID of the possibly (running) process # find out the processID of the possibly (running) process
obsid=() obsid=()
pid_user=() pid_user=()
pidof -x ${prog} 1>/dev/null 2>&1 $PIDOF -x ${prog} 1>/dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
pid=( `pidof -x ${prog}` ) pid=( `$PIDOF -x ${prog}` )
i=0 i=0
for apid in ${pid[@]} for apid in ${pid[@]}
do do
...@@ -522,7 +525,7 @@ goto_level() ...@@ -522,7 +525,7 @@ goto_level()
# set rcumode to 0 (power save) when entering level 1 # set rcumode to 0 (power save) when entering level 1
if [ ${newlevel} -le 1 ]; then if [ ${newlevel} -le 1 ]; then
if [ ${curlevel} -ge 2 ]; then if [ ${curlevel} -ge 2 ]; then
pidof RSPDriver 1>/dev/null 2>&1 $PIDOF RSPDriver 1>/dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
status=`( rspctl --version | grep "0.0" ) >& /dev/null; echo $?` status=`( rspctl --version | grep "0.0" ) >& /dev/null; echo $?`
if [ $status == 1 ]; then if [ $status == 1 ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment