X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=sidecars%2Flistener%2Frun_replay.sh;h=b21e7ae2ef410d5e8551feb17fbf618d84bbb2ca;hb=05bb70aef70472a386bd2c0218fc1fa398d41f22;hp=d3cb6725d14489ac7e1f8925b03ace83e412b321;hpb=3cbdc585f92f4299f4e05108f9ed76766a72ff84;p=ric-app%2Fmc.git diff --git a/sidecars/listener/run_replay.sh b/sidecars/listener/run_replay.sh index d3cb672..b21e7ae 100755 --- a/sidecars/listener/run_replay.sh +++ b/sidecars/listener/run_replay.sh @@ -37,15 +37,29 @@ fifo_dir=/var/lib/mc/listener data="" # stdin by default +pre_open=0 +mtype_list="" +gate="" +delay=0 while [[ $1 == -* ]] do case $1 in - -f) data=$2; shift;; + -f) data="$2"; shift;; -d) fifo_dir=$2; shift;; + -D) delay=$2; shift;; + -g) gate="$2"; shift;; + -m) mtype_list="$2"; shift;; + -p) pre_open=1;; *) echo "$1 is not a recognised option" - echo "usage: $0 [-d fifo-dir] [-f data-file]" + echo "usage: $0 [-d fifo-dir] [-D seconds] [-f data-file] [-g gate-file] [-m mtype-list] [-p]" + echo " -p causes FIFOs to be pre-allocated" + echo " -m supplies a comma separated list of message types to preopen FIFOs for" + echo " if -p is given and -m is omitted, the input file is examined to determine message types" + echo " -D seconds will cause a delay of the specified number of seconds before starting the replay" + echo " -g file will cause the script to wait for file to appear before starting the replay" + echo " if both -D and -g are used, the delay happens after the gate file is found" exit 1 ;; esac @@ -53,6 +67,42 @@ do shift done +if (( pre_open )) +then + if [[ -z $mtype_list ]] + then + if [[ -z $data ]] + then + echo "error: cannot determine a mtype list from stdin:" + echo " -p given with out a list (-m) and input file set to default to stdin (missing -f)" + exit 1 + fi + + rdc_extract $data 0 | sort -u | while read t + do + mtype_list="$mtype_list$t " + done + fi + + ( + cd $fifo_dir + count=0 + for t in ${mtype_list//,/ } + do + name=$( printf "MT_%09d" t ) + echo "making FIFO: $name" + mkfifo -m 664 $name 2>/dev/null # if these are there, don't natter on about them + (( count++ )) + done + + ls MT_* | wc -l | read found + if (( count != found )) + then + echo "warn: after pre-create, expected $count FIFOs, but found only $found" + fi + ) +fi + if [[ -n $data ]] then if [[ ! -r $data ]] @@ -60,7 +110,29 @@ then echo "abort: cannot find data file: $data" exit 1 fi + + data="-f $data" +fi + +if [[ -n $gate ]] +then + echo "waiting for gate file to appear: $gate" + while true + do + if [[ -e $gate ]] + then + break + fi + sleep 1 + done +fi + +if (( delay )) +then + echo "pausing $delay seconds before starting rdc_display..." + sleep $delay fi +echo "starting rdc_replay" rdc_replay -d $fifo_dir $data