From 1f851eb86ea68f4c3796cc62e3aacc2b82a92040 Mon Sep 17 00:00:00 2001
From: Florian Uhlig <f.uhlig@gsi.de>
Date: Tue, 22 Feb 2022 18:13:01 +0100
Subject: [PATCH] Call the correct executable for shmem cleanup

The cleanup of the shared memory wasn't working anymore. The executable is
a part of FairMQ which was moved from FairRoot in its own package. Also the
name of the excutable has changed to fairmq-shmmonitor which is now installed
in SIMPATH.

Remove blank characters from the end of lines.
---
 ...MQSamplerUnpackerParserverHitBuilder.sh.in | 45 ++++++++++---------
 MQ/hitbuilder/startMQ_Mcbm.sh.in              | 44 +++++++++---------
 MQ/sink/startMQSamplerSink.sh.in              |  8 ++--
 MQ/source/startMQInfo.sh.in                   |  8 ++--
 MQ/source/startMQSampler.sh.in                | 10 ++---
 MQ/sts/startTest.sh.in                        |  8 ++--
 .../startMQSamplerUnpackerParserver.sh.in     |  8 ++--
 7 files changed, 71 insertions(+), 60 deletions(-)

diff --git a/MQ/hitbuilder/startMQSamplerUnpackerParserverHitBuilder.sh.in b/MQ/hitbuilder/startMQSamplerUnpackerParserverHitBuilder.sh.in
index 604927c744..eb478dcd08 100755
--- a/MQ/hitbuilder/startMQSamplerUnpackerParserverHitBuilder.sh.in
+++ b/MQ/hitbuilder/startMQSamplerUnpackerParserverHitBuilder.sh.in
@@ -1,23 +1,24 @@
-
 #!/bin/bash
 
 Running=`ps uaxww | grep HitB`
 
-if [[ $Running == *"hitbuilder1"* ]]; then 
+if [[ $Running == *"hitbuilder1"* ]]; then
     echo Hitbuilder is still running, wait or cleanup!
-    exit 1 
+    exit 1
 fi
 
-$FAIRROOTPATH/bin/shmmonitor --cleanup
+if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
+  @SIMPATH@/bin/fairmq-shmmonitor --cleanup
+fi
 
-if [ -z "$1" ]; then 
+if [ -z "$1" ]; then
     _runname="r0088_20180905_1602"
-else 
+else
     _runname=$1
 fi
-  
-_reqmod=3 
-_reqtint=100 
+
+_reqmod=3
+_reqtint=100
 _batch=1
 _iUnp=6
 
@@ -25,18 +26,18 @@ _dirname=@VMCWORKDIR@/macro/beamtime/star2019/input/$_runname/
 _filename=$_runname_*.tsa
 _digifile=$_runname.$_reqtint.$_reqmod.root
 
-# ASCII files  
+# ASCII files
 _mapfile=@CMAKE_CURRENT_SOURCE_DIR@/MapTofGbtx.par
 #_digibdffile=@CMAKE_CURRENT_SOURCE_DIR@/v18j_cosmicHD.digibdf.par
 #_digiparfile=@CMAKE_CURRENT_SOURCE_DIR@/tof_v18j_cosmicHD.digi.par
 _digibdffile=@VMCWORKDIR@/parameters/tof/v18_star_cosmics.digibdf.par
 _digiparfile=@VMCWORKDIR@/parameters/tof/tof_v18_star_cosmics.digi.par
 
-# ROOT files 
+# ROOT files
 #_geofile=@CMAKE_CURRENT_SOURCE_DIR@/tof_v18j_cosmicHD.par.root
 _geofile=@CMAKE_CURRENT_SOURCE_DIR@/tof_v18_star_cosmics.par.root
 
-rm -v nohup.out 
+rm -v nohup.out
 rm -v *log
 rm all_*
 
@@ -53,7 +54,7 @@ PARAMETERSERVER+=" --first-input-type ASCII"
 PARAMETERSERVER+=" --second-input-name $_geofile"
 PARAMETERSERVER+=" --second-input-type ROOT"
 PARAMETERSERVER+=" --verbosity INFO"
-if  [[ $_batch = 1 ]]; then 
+if  [[ $_batch = 1 ]]; then
 PARAMETERSERVER+=" --control static"
 PARAMETERSERVER+=" --log-to-file ParServ.out"
 nohup @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &
@@ -78,14 +79,14 @@ SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,transport=zeromq,ad
 #SAMPLER+=" --verbosity WARN"
 SAMPLER+=" --verbosity INFO"
 #SAMPLER+=" --verbosity DEBUG"
-if  [[ $_batch = 1 ]]; then 
+if  [[ $_batch = 1 ]]; then
 SAMPLER+=" --log-to-file Sampl.out"
 SAMPLER+=" --control static"
-nohup  @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER & 
-else 
+nohup  @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
+else
 xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
 fi
- 
+
 while (( _iUnp > 0 )); do
 
 UNPACKER="UnpackTofMcbm2018"
@@ -117,16 +118,16 @@ UNPACKER+=" --ReqDet14 131110"
 UNPACKER+=" --ReqDet15 131126"
 UNPACKER+=" --ReqDet16 131142"
 UNPACKER+=" --ReqDet17 131158"
-if  [[ $_batch = 1 ]]; then 
+if  [[ $_batch = 1 ]]; then
 UNPACKER+=" --control static"
 UNPACKER+=" --log-to-file Unp.out"
 nohup @CMAKE_BINARY_DIR@/bin/MQ/unpacker/$UNPACKER &
-else 
-xterm -geometry 110x23+520+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/unpacker/$UNPACKER & 
+else
+xterm -geometry 110x23+520+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/unpacker/$UNPACKER &
 fi
 
 (( _iUnp -= 1 ))
-done 
+done
 
 HITBUILDER="HitBuilderTof"
 HITBUILDER+=" --id hitbuilder1"
@@ -144,7 +145,7 @@ HITBUILDER+=" --OutRootFile $_digifile"
 HITBUILDER+=" --RunId 1538835959"
 #HITBUILDER+=" --RunId 1536669562"
 #HITBUILDER+=" --RunId 1537898701"
-if  [[ $_batch = 1 ]]; then 
+if  [[ $_batch = 1 ]]; then
 HITBUILDER+=" --control static"
 HITBUILDER+=" --log-to-file HitBuild.out"
 nohup  @CMAKE_BINARY_DIR@/bin/MQ/hitbuilder/$HITBUILDER &
diff --git a/MQ/hitbuilder/startMQ_Mcbm.sh.in b/MQ/hitbuilder/startMQ_Mcbm.sh.in
index 79bdab15c8..59809baec4 100755
--- a/MQ/hitbuilder/startMQ_Mcbm.sh.in
+++ b/MQ/hitbuilder/startMQ_Mcbm.sh.in
@@ -1,33 +1,35 @@
 #!/bin/bash
-$FAIRROOTPATH/bin/shmmonitor --cleanup
+if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
+  @SIMPATH@/bin/fairmq-shmmonitor --cleanup
+fi
 
-if [ -z "$1" ]; then 
+if [ -z "$1" ]; then
     _runname="r0088_20180905_1602"
-else 
+else
     _runname=$1
 fi
-  
+
 _reqmod=3
 _reqtint=50
 _ntimeslices=-1
 _iUnp=4
 _batch=1
-_pulmode=1 
+_pulmode=1
 _pulmulmin=9
 _pultotmin=50
-#_tshiftref=0. 
-_tshiftref=-35. 
+#_tshiftref=0.
+_tshiftref=-35.
 
 #_dirname=@VMCWORKDIR@/macro/beamtime/mcbm2018/input/$_runname/
 _outdir=@VMCWORKDIR@/macro/beamtime/mcbm2018/data/
 #_datapath=~/KRONOS/CBM/cbmroot/trunk
 #_dirname=$_datapath/macro/beamtime/mcbm2018/input/$_runname/
 #_outdir=$_datapath/macro/beamtime/mcbm2018/data/
- 
+
 _filename="./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa"
 _digifile=$_runname.$_reqtint.$_reqmod.$_pulmode.root
 
-# ASCII files  
+# ASCII files
 #_mapfile=@CMAKE_CURRENT_SOURCE_DIR@/MapTofGbtx.par
 _mapfile=@VMCWORKDIR@/macro/beamtime/mcbm2018/mTofPar.par
 #_mapfile=@VMCWORKDIR@/macro/beamtime/mcbm2018/etofPar.par
@@ -36,10 +38,10 @@ _mapfile=@VMCWORKDIR@/macro/beamtime/mcbm2018/mTofPar.par
 _digibdffile=@VMCWORKDIR@/parameters/tof/v18l_mCbm.digibdf.par
 _digiparfile=@VMCWORKDIR@/parameters/tof/tof_v18l_mCbm.digi.par
 
-# ROOT files 
+# ROOT files
 _geofile=@VMCWORKDIR@/macro/beamtime/mcbm2018/tof_v18l_mCbm.par.root
 
-rm -v nohup.out 
+rm -v nohup.out
 rm -v *log
 rm all_*
 
@@ -57,7 +59,7 @@ PARAMETERSERVER+=" --first-input-type ASCII"
 PARAMETERSERVER+=" --second-input-name $_geofile"
 PARAMETERSERVER+=" --second-input-type ROOT"
 PARAMETERSERVER+=" --severity INFO"
-if  [[ $_batch = 1 ]]; then 
+if  [[ $_batch = 1 ]]; then
 PARAMETERSERVER+=" --control static"
 PARAMETERSERVER+=" --log-to-file ParServ.out"
 nohup @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &
@@ -82,14 +84,14 @@ SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,transport=zeromq,ad
 #SAMPLER+=" --severity WARN"
 SAMPLER+=" --severity INFO"
 #SAMPLER+=" --severity DEBUG"
-if  [[ $_batch = 1 ]]; then 
+if  [[ $_batch = 1 ]]; then
 SAMPLER+=" --log-to-file Sampl.out"
 SAMPLER+=" --control static"
-nohup  @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER & 
-else 
+nohup  @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
+else
 xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
 fi
- 
+
 while (( _iUnp > 0 )); do
 
 UNPACKER="UnpackTofMcbm2018"
@@ -107,16 +109,16 @@ UNPACKER+=" --PulserMode $_pulmode"
 UNPACKER+=" --PulMulMin $_pulmulmin"
 UNPACKER+=" --PulTotMin $_pultotmin"
 UNPACKER+=" --TShiftRef $_tshiftref"
-if  [[ $_batch = 1 ]]; then 
+if  [[ $_batch = 1 ]]; then
 UNPACKER+=" --control static"
 UNPACKER+=" --log-to-file Unp.out"
 nohup @CMAKE_BINARY_DIR@/bin/MQ/unpacker/$UNPACKER &
-else 
-xterm -geometry 110x23+520+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/unpacker/$UNPACKER & 
+else
+xterm -geometry 110x23+520+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/unpacker/$UNPACKER &
 fi
 
 (( _iUnp -= 1 ))
-done 
+done
 
 HITBUILDER="HitBuilderTof"
 HITBUILDER+=" --id hitbuilder1"
@@ -148,7 +150,7 @@ HITBUILDER+=" --Sel2Type  0"
 HITBUILDER+=" --Sel2Sm    2"
 HITBUILDER+=" --Sel2Rpc   2"
 
-if  [[ $_batch = 1 ]]; then 
+if  [[ $_batch = 1 ]]; then
 HITBUILDER+=" --control static"
 HITBUILDER+=" --log-to-file HitBuild.out"
 nohup  @CMAKE_BINARY_DIR@/bin/MQ/hitbuilder/$HITBUILDER &
diff --git a/MQ/sink/startMQSamplerSink.sh.in b/MQ/sink/startMQSamplerSink.sh.in
index 450e7ee4b1..8aeaf9c6fb 100755
--- a/MQ/sink/startMQSamplerSink.sh.in
+++ b/MQ/sink/startMQSamplerSink.sh.in
@@ -1,10 +1,12 @@
 #!/bin/bash
-$FAIRROOTPATH/bin/shmmonitor --cleanup
+if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
+  @SIMPATH@/bin/fairmq-shmmonitor --cleanup
+fi
 
-if [ -z "$1" ]; then 
+if [ -z "$1" ]; then
 #    _filename=@VMCWORKDIR@/input/stsxyter_cosy2018.tsa
     _filename=@VMCWORKDIR@/input/tofget4_hd2018.tsa
-else 
+else
     _filename=$1
 fi
 
diff --git a/MQ/source/startMQInfo.sh.in b/MQ/source/startMQInfo.sh.in
index 6338ae8a80..5515ce9c08 100755
--- a/MQ/source/startMQInfo.sh.in
+++ b/MQ/source/startMQInfo.sh.in
@@ -1,10 +1,12 @@
 #!/bin/bash
-$FAIRROOTPATH/bin/shmmonitor --cleanup
+if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
+  @SIMPATH@/bin/fairmq-shmmonitor --cleanup
+fi
 
-if [ -z "$1" ]; then 
+if [ -z "$1" ]; then
 #    _filename=@VMCWORKDIR@/input/stsxyter_cosy2018.tsa
     _filename=@VMCWORKDIR@/input/tofget4_hd2018.tsa
-else 
+else
     _filename=$1
 fi
 
diff --git a/MQ/source/startMQSampler.sh.in b/MQ/source/startMQSampler.sh.in
index a9d3d71aa8..678a2a52dc 100755
--- a/MQ/source/startMQSampler.sh.in
+++ b/MQ/source/startMQSampler.sh.in
@@ -1,13 +1,13 @@
 #!/bin/bash
-if [ -e $FAIRROOTPATH/bin/shmmonitor ]; then
-  $FAIRROOTPATH/bin/shmmonitor --cleanup
-fi 
+if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
+  @SIMPATH@/bin/fairmq-shmmonitor --cleanup
+fi
 
-if [ -z "$1" ]; then 
+if [ -z "$1" ]; then
 #    _filename=@VMCWORKDIR@/input/stsxyter_cosy2018.tsa
     _filename=tofget4_hd2018.tsa
     _dirname=@VMCWORKDIR@/input/
-else 
+else
     _filename=$1
     _dirname=$2
 fi
diff --git a/MQ/sts/startTest.sh.in b/MQ/sts/startTest.sh.in
index b3456318d5..4345a41173 100755
--- a/MQ/sts/startTest.sh.in
+++ b/MQ/sts/startTest.sh.in
@@ -1,9 +1,11 @@
 #!/bin/bash
-$FAIRROOTPATH/bin/shmmonitor --cleanup
+if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
+  @SIMPATH@/bin/fairmq-shmmonitor --cleanup
+fi
 
-if [ -z "$1" ]; then 
+if [ -z "$1" ]; then
     _run_id="1568041655"
-else 
+else
     _run_id=$1
 fi
 
diff --git a/MQ/unpacker/startMQSamplerUnpackerParserver.sh.in b/MQ/unpacker/startMQSamplerUnpackerParserver.sh.in
index 578e24dd03..edb573e8c8 100755
--- a/MQ/unpacker/startMQSamplerUnpackerParserver.sh.in
+++ b/MQ/unpacker/startMQSamplerUnpackerParserver.sh.in
@@ -1,9 +1,11 @@
 #!/bin/bash
-$FAIRROOTPATH/bin/shmmonitor --cleanup
+if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
+  @SIMPATH@/bin/fairmq-shmmonitor --cleanup
+fi
 
-if [ -z "$1" ]; then 
+if [ -z "$1" ]; then
     _filename=@VMCWORKDIR@/input/tofget4_hd2018.tsa
-else 
+else
     _filename=$1
 fi
 
-- 
GitLab