Use the prevalent Sipwise coding style. Change-Id: I50fb2ee49c188b65ea7151c8b097fe39dc6b3101changes/54/39054/1
parent
624139ffcf
commit
29d5761bec
@ -1,50 +1,51 @@
|
||||
#!/bin/bash
|
||||
CURL="/usr/bin/curl"
|
||||
CREDS="$HOME/.ngcp-api"
|
||||
CREDS="${HOME}/.ngcp-api"
|
||||
TOOLS="/usr/share/ngcp-panel-tools/ngcp-api.inc"
|
||||
|
||||
usage () {
|
||||
cat << EOF
|
||||
cat << EOF
|
||||
Usage: $0 [OPTIONS] <url>
|
||||
|
||||
sends a get request to NGCP REST API
|
||||
|
||||
OPTIONS:
|
||||
-h this help
|
||||
-v verbose mode
|
||||
-h this help
|
||||
-v verbose mode
|
||||
EOF
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ -z "$APIUSER" ] ; then
|
||||
if [ -f "$TOOLS" ] ; then
|
||||
source "$TOOLS"
|
||||
importcreds "$CREDS"
|
||||
else
|
||||
APIUSER="administrator:administrator"
|
||||
fi
|
||||
if [ -z "${APIUSER}" ]; then
|
||||
if [ -f "${TOOLS}" ]; then
|
||||
source "${TOOLS}"
|
||||
importcreds "${CREDS}"
|
||||
else
|
||||
APIUSER="administrator:administrator"
|
||||
fi
|
||||
fi
|
||||
HEADERS="-H 'Connection: close'"
|
||||
|
||||
while getopts "hv" OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
h)
|
||||
usage
|
||||
;;
|
||||
v)
|
||||
VERBOSE="--verbose"
|
||||
;;
|
||||
?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
case ${OPTION} in
|
||||
h)
|
||||
usage
|
||||
;;
|
||||
v)
|
||||
VERBOSE="--verbose"
|
||||
;;
|
||||
?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
URL="$1"
|
||||
if [ -z "$URL" ] ; then
|
||||
usage
|
||||
if [ -z "${URL}" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
${CURL} -i ${VERBOSE} -X GET "$HEADERS" --user "$APIUSER" --insecure "$URL"
|
||||
${CURL} -i ${VERBOSE} -X GET \
|
||||
-H 'Connection: close' \
|
||||
--user "${APIUSER}" --insecure "${URL}"
|
||||
|
||||
Loading…
Reference in new issue