File tree Expand file tree Collapse file tree 1 file changed +41
-4
lines changed Expand file tree Collapse file tree 1 file changed +41
-4
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
- for i in /api/8/processes /api/8/connections /api/8/slabs /api/8/http/requests /api/8/http/server_zones /api/8/http/location_zones /api/8/http/caches /api/8/http/upstreams /api/8/http/keyvals; do
3
- echo " **** $i ****" ;
4
- curl -s " 127.0.0.1:8080/$i " | jq . ;
5
- echo " " ;
2
+
3
+ # Parse command line options
4
+ set -e
5
+ set -o pipefail
6
+ while getopts " p:v:h" opt; do
7
+ case $opt in
8
+ p) API_PORT=" $OPTARG "
9
+ ;;
10
+ h) echo " Usage: $0 [-p port]"
11
+ exit 0
12
+ ;;
13
+ \? ) echo " Invalid option -$OPTARG " >&2
14
+ echo " Usage: $0 [-p port]"
15
+ exit 1
16
+ ;;
17
+ esac
18
+ done
19
+
20
+ if [ $OPTIND -eq 1 ]; then
21
+ echo " No options were passed, exiting ..."
22
+ echo " Usage: $( basename " $0 " ) [-p port]"
23
+ exit 1
24
+ fi
25
+
26
+ if [ -z " ${API_PORT} " ]; then
27
+ echo ' Missing -p arg' >&2
28
+ exit 1
29
+ fi
30
+
31
+ api_versions=($( curl http://127.0.0.1:$API_PORT /api/ | sed -e ' s/\[//g' -e ' s/\]//g' -e ' s/\,/ /g' ) )
32
+ API_VERSION=${api_versions[-1]}
33
+ echo " API_VERSION: $API_VERSION "
34
+
35
+ echo " **** /api/$API_VERSION /nginx ****" ;
36
+ curl -s " 127.0.0.1:$API_PORT /api/$API_VERSION /nginx" | jq . ;
37
+ echo " " ;
38
+
39
+ for i in /api/$API_VERSION /processes /api/$API_VERSION /connections /api/$API_VERSION /slabs /api/$API_VERSION /http/requests /api/$API_VERSION /http/server_zones /api/$API_VERSION /http/location_zones /api/$API_VERSION /http/caches /api/$API_VERSION /http/upstreams /api/$API_VERSION /http/keyvals; do
40
+ echo " **** $i ****" ;
41
+ curl -s " 127.0.0.1:$API_PORT /$i " | jq . ;
42
+ echo " " ;
6
43
done
You can’t perform that action at this time.
0 commit comments