blob: e68e7e58272b37a637769f81159562e00edbee39 [file] [log] [blame]
Oliver Smithdef05d32019-12-02 15:02:22 +01001#!/bin/sh -e
Daniel Willmanne7a57642019-06-19 14:21:28 +02002
Oliver Smithdef05d32019-12-02 15:02:22 +01003require_osmo_interact_vty() {
4 if command -v osmo_interact_vty.py >/dev/null 2>&1; then
5 return
6 fi
7 echo "ERROR: osmo_interact_vty.py not found. Are osmo-python-tests in PATH?"
Daniel Willmanne7a57642019-06-19 14:21:28 +02008 exit 1
Oliver Smithdef05d32019-12-02 15:02:22 +01009}
Daniel Willmanne7a57642019-06-19 14:21:28 +020010
Oliver Smithdef05d32019-12-02 15:02:22 +010011# $1: "update_vty_reference" or "update_counters"
12# $2: output file
13# $3: port
14# $4-$n: command
15interact_vty() {
16 action="$1"
17 output="$2"
18 port="$3"
19 log="/tmp/$4.log"
20 shift 3
Daniel Willmanne7a57642019-06-19 14:21:28 +020021
Oliver Smithdef05d32019-12-02 15:02:22 +010022 echo "Starting in background: $@"
23 "$@" > "$log" 2>&1 &
24 pid="$!"
Daniel Willmanne7a57642019-06-19 14:21:28 +020025
Oliver Smithdef05d32019-12-02 15:02:22 +010026 sleep 0.5
27 if ! kill -0 "$pid" 2>/dev/null; then
28 echo "ERROR: start failed!"
29 cat "$log"
30 exit 1
31 fi
Daniel Willmanne7a57642019-06-19 14:21:28 +020032
Oliver Smithdef05d32019-12-02 15:02:22 +010033 case "$action" in
34 "update_vty_reference")
35 echo "Updating VTY reference: $output"
36 osmo_interact_vty.py -X -p "$port" -H 127.0.0.1 -O "$output"
37 ;;
38 "update_counters")
39 echo "Updating asciidoc counters: $output"
40 osmo_interact_vty.py -c "enable;show asciidoc counters" -p "$port" -H 127.0.0.1 -O "$output"
41 ;;
42 *)
43 echo "ERROR: invalid argument: $action"
44 exit 1
45 ;;
46 esac
47
48 kill "$pid"
49 echo "Done (killed $1)"
50 echo
51}
52
53DIR="$(cd "$(dirname "$0")"; pwd)"
Harald Welte936dfd72021-01-31 19:36:06 +010054echo $DIR
Oliver Smithdef05d32019-12-02 15:02:22 +010055cd "$DIR"
56
57require_osmo_interact_vty
58
59interact_vty \
60 "update_vty_reference" \
Harald Welte936dfd72021-01-31 19:36:06 +010061 "vty/gbproxy_vty_reference.xml" \
Oliver Smithdef05d32019-12-02 15:02:22 +010062 4246 \
63 osmo-gbproxy -c "../examples/osmo-gbproxy/osmo-gbproxy.cfg"
64
Harald Welte936dfd72021-01-31 19:36:06 +010065sleep 5
66
Oliver Smithdef05d32019-12-02 15:02:22 +010067interact_vty \
68 "update_counters" \
69 "chapters/counters_generated.adoc" \
Harald Welte936dfd72021-01-31 19:36:06 +010070 4246 \
71 osmo-gbproxy -c "../examples/osmo-gbproxy/osmo-gbproxy.cfg"
Oliver Smithdef05d32019-12-02 15:02:22 +010072
73
74echo "Done with all"