blob: 847b764aada8eb90e46016200cac652d4694b6f2 [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)"
54cd "$DIR"
55
56require_osmo_interact_vty
57
58interact_vty \
59 "update_vty_reference" \
60 "vty/sgsn_vty_reference.xml" \
61 4245 \
62 osmo-sgsn -c "../examples/osmo-sgsn/osmo-sgsn.cfg"
63
64interact_vty \
65 "update_vty_reference" \
66 "vty-osmogbproxy/gbproxy_vty_reference.xml" \
67 4246 \
68 osmo-gbproxy -c "../examples/osmo-gbproxy/osmo-gbproxy.cfg"
69
70interact_vty \
71 "update_counters" \
72 "chapters/counters_generated.adoc" \
73 4245 \
74 osmo-sgsn -c "../examples/osmo-sgsn/osmo-sgsn.cfg"
75
76
77echo "Done with all"