Oliver Smith | def05d3 | 2019-12-02 15:02:22 +0100 | [diff] [blame^] | 1 | #!/bin/sh -e |
Daniel Willmann | e7a5764 | 2019-06-19 14:21:28 +0200 | [diff] [blame] | 2 | |
Oliver Smith | def05d3 | 2019-12-02 15:02:22 +0100 | [diff] [blame^] | 3 | require_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 Willmann | e7a5764 | 2019-06-19 14:21:28 +0200 | [diff] [blame] | 8 | exit 1 |
Oliver Smith | def05d3 | 2019-12-02 15:02:22 +0100 | [diff] [blame^] | 9 | } |
Daniel Willmann | e7a5764 | 2019-06-19 14:21:28 +0200 | [diff] [blame] | 10 | |
Oliver Smith | def05d3 | 2019-12-02 15:02:22 +0100 | [diff] [blame^] | 11 | # $1: "update_vty_reference" or "update_counters" |
| 12 | # $2: output file |
| 13 | # $3: port |
| 14 | # $4-$n: command |
| 15 | interact_vty() { |
| 16 | action="$1" |
| 17 | output="$2" |
| 18 | port="$3" |
| 19 | log="/tmp/$4.log" |
| 20 | shift 3 |
Daniel Willmann | e7a5764 | 2019-06-19 14:21:28 +0200 | [diff] [blame] | 21 | |
Oliver Smith | def05d3 | 2019-12-02 15:02:22 +0100 | [diff] [blame^] | 22 | echo "Starting in background: $@" |
| 23 | "$@" > "$log" 2>&1 & |
| 24 | pid="$!" |
Daniel Willmann | e7a5764 | 2019-06-19 14:21:28 +0200 | [diff] [blame] | 25 | |
Oliver Smith | def05d3 | 2019-12-02 15:02:22 +0100 | [diff] [blame^] | 26 | 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 Willmann | e7a5764 | 2019-06-19 14:21:28 +0200 | [diff] [blame] | 32 | |
Oliver Smith | def05d3 | 2019-12-02 15:02:22 +0100 | [diff] [blame^] | 33 | 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 | |
| 53 | DIR="$(cd "$(dirname "$0")"; pwd)" |
| 54 | cd "$DIR" |
| 55 | |
| 56 | require_osmo_interact_vty |
| 57 | |
| 58 | interact_vty \ |
| 59 | "update_vty_reference" \ |
| 60 | "vty/sgsn_vty_reference.xml" \ |
| 61 | 4245 \ |
| 62 | osmo-sgsn -c "../examples/osmo-sgsn/osmo-sgsn.cfg" |
| 63 | |
| 64 | interact_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 | |
| 70 | interact_vty \ |
| 71 | "update_counters" \ |
| 72 | "chapters/counters_generated.adoc" \ |
| 73 | 4245 \ |
| 74 | osmo-sgsn -c "../examples/osmo-sgsn/osmo-sgsn.cfg" |
| 75 | |
| 76 | |
| 77 | echo "Done with all" |