d3cb6725d14489ac7e1f8925b03ace83e412b321
[ric-app/mc.git] / sidecars / listener / run_replay.sh
1 #!/usr/bin/env bash
2 # vim: ts=4 sw=4 noet:
3 #----------------------------------------------------------------------------------
4 #
5 #       Copyright (c) 2018-2019 AT&T Intellectual Property.
6 #
7 #   Licensed under the Apache License, Version 2.0 (the "License");
8 #   you may not use this file except in compliance with the License.
9 #   You may obtain a copy of the License at
10 #
11 #          http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #   Unless required by applicable law or agreed to in writing, software
14 #   distributed under the License is distributed on an "AS IS" BASIS,
15 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #   See the License for the specific language governing permissions and
17 #   limitations under the License.
18 #
19 #---------------------------------------------------------------------------------
20
21
22 # ----------------------------------------------------------------------
23 # Mnemonic:     run_replay.sh
24 # Abstract: Simple script to make starting the replay binary easier.
25 #                       Defaults:
26 #                               /var/lib/mc/listener  -- directory for fifos
27 #
28 #                       The input file can be supplied with -f and if omitted then
29 #                       standard intput is assumed. This should allow the following
30 #                       when run in a docker container:
31 #                               docker run --rm -i -v /tmp/replay_fifos:/var/lib/mc/listener run_replay.sh <data-file
32 #
33 # Date:         20 November 2019
34 # Author:       E. Scott Daniels
35 # ----------------------------------------------------------------------
36
37
38 fifo_dir=/var/lib/mc/listener
39 data=""                                                         # stdin by default
40
41 while [[ $1 == -* ]]
42 do
43         case $1 in 
44                 -f) data=$2; shift;;
45                 -d)     fifo_dir=$2; shift;;
46
47                 *)      echo "$1 is not a recognised option"
48                         echo "usage: $0 [-d fifo-dir] [-f data-file]"
49                         exit 1
50                         ;;
51         esac
52
53         shift
54 done
55
56 if [[ -n $data ]]
57 then
58         if [[ ! -r $data ]]
59         then
60                 echo "abort: cannot find data file: $data"
61                 exit 1
62         fi
63 fi
64
65 rdc_replay -d $fifo_dir $data
66