diff --git a/tools_bin/ngcp-api-delete b/tools_bin/ngcp-api-delete index eaef3a77d7..3ff09731bd 100755 --- a/tools_bin/ngcp-api-delete +++ b/tools_bin/ngcp-api-delete @@ -1,10 +1,10 @@ #!/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] sends a delete request to NGCP REST API @@ -13,38 +13,39 @@ OPTIONS: -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 DELETE "$HEADERS" --user "$APIUSER" --insecure "$URL" +${CURL} -i ${VERBOSE} -X DELETE \ + -H 'Connection: close' \ + "${HEADERS}" --user "${APIUSER}" --insecure "${URL}" diff --git a/tools_bin/ngcp-api-get b/tools_bin/ngcp-api-get index ddbc91dca2..0c94dd7799 100755 --- a/tools_bin/ngcp-api-get +++ b/tools_bin/ngcp-api-get @@ -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] 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}" diff --git a/tools_bin/ngcp-api-patch b/tools_bin/ngcp-api-patch index 045d3fa870..e2565e5287 100755 --- a/tools_bin/ngcp-api-patch +++ b/tools_bin/ngcp-api-patch @@ -1,10 +1,10 @@ #!/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] sends a patch request to NGCP REST API @@ -15,13 +15,13 @@ OPTIONS: -f read the input info from a file instead of read stdin -m use Header 'Refer: return=minimal' EOF - exit 1 + exit 1 } -if [ -z "$APIUSER" ] ; then - if [ -f "$TOOLS" ] ; then - source "$TOOLS" - importcreds "$CREDS" +if [ -z "${APIUSER}" ]; then + if [ -f "${TOOLS}" ]; then + source "${TOOLS}" + importcreds "${CREDS}" else APIUSER="administrator:administrator" fi @@ -32,37 +32,37 @@ PREFER="representation" while getopts "mf:hv" OPTION do - case $OPTION in - h) - usage - ;; - f) - INPUT=() - FILE_INPUT=(--data-binary @$OPTARG) - if [ ! -f "$OPTARG" ]; then - echo "No '$OPTARG' file found" - usage - fi - ;; - m) - PREFER="minimal" - ;; - v) - VERBOSE="--verbose" - ;; - ?) - usage - ;; - esac + case ${OPTION} in + h) + usage + ;; + f) + INPUT=() + FILE_INPUT=(--data-binary @${OPTARG}) + if [ ! -f "${OPTARG}" ]; then + echo "No '${OPTARG}' file found" + usage + fi + ;; + m) + PREFER="minimal" + ;; + v) + VERBOSE="--verbose" + ;; + ?) + usage + ;; + esac done shift $((OPTIND - 1)) URL="$1" -if [ -z "$URL" ] ; then +if [ -z "${URL}" ] ; then usage fi ${CURL} -i ${VERBOSE} -X PATCH \ - -H 'Connection: close' -H "Prefer: return=$PREFER" \ - -H "Content-Type: $CTYPE" \ - --user "$APIUSER" --insecure "${FILE_INPUT[@]}" "$URL" "${INPUT[@]}" + -H 'Connection: close' -H "Prefer: return=${PREFER}" \ + -H "Content-Type: ${CTYPE}" \ + --user "${APIUSER}" --insecure "${FILE_INPUT[@]}" "${URL}" "${INPUT[@]}" diff --git a/tools_bin/ngcp-api-post b/tools_bin/ngcp-api-post index 5c0e74200f..552361bdb9 100755 --- a/tools_bin/ngcp-api-post +++ b/tools_bin/ngcp-api-post @@ -1,10 +1,10 @@ #!/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] [content-type] sends a post request to NGCP REST API @@ -14,50 +14,50 @@ OPTIONS: -v verbose mode -f read the input info from a file instead of read stdin 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 INPUT=(-T -) while getopts "f:hv" OPTION do - case $OPTION in - h) - usage - ;; - f) - INPUT=() - FILE_INPUT=(--data-binary @$OPTARG) - if [ ! -f "$OPTARG" ]; then - echo "No '$OPTARG' file found" - usage - fi - ;; - v) - VERBOSE="--verbose" - ;; - ?) - usage - ;; - esac + case ${OPTION} in + h) + usage + ;; + f) + INPUT=() + FILE_INPUT=(--data-binary @${OPTARG}) + if [ ! -f "${OPTARG}" ]; then + echo "No '{$OPTARG}' file found" + usage + fi + ;; + v) + VERBOSE="--verbose" + ;; + ?) + usage + ;; + esac done shift $((OPTIND - 1)) URL="$1" -if [ -z "$URL" ] ; then - usage +if [ -z "${URL}" ]; then + usage fi CTYPE=${2:-application/json} ${CURL} -i ${VERBOSE} -X POST \ - -H 'Connection: close' -H 'Prefer: return=representation' \ - -H "Content-Type: $CTYPE" \ - --user "$APIUSER" --insecure "${FILE_INPUT[@]}" "$URL" "${INPUT[@]}" + -H 'Connection: close' -H 'Prefer: return=representation' \ + -H "Content-Type: ${CTYPE}" \ + --user "${APIUSER}" --insecure "${FILE_INPUT[@]}" "${URL}" "${INPUT[@]}" diff --git a/tools_bin/ngcp-api-put b/tools_bin/ngcp-api-put index 81e238d259..6b2c5e4b40 100755 --- a/tools_bin/ngcp-api-put +++ b/tools_bin/ngcp-api-put @@ -1,10 +1,10 @@ #!/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] [content-type] sends a put request to NGCP REST API @@ -14,13 +14,13 @@ OPTIONS: -v verbose mode -f read the input info from a file instead of read stdin EOF - exit 1 + exit 1 } -if [ -z "$APIUSER" ] ; then - if [ -f "$TOOLS" ] ; then - source "$TOOLS" - importcreds "$CREDS" +if [ -z "${APIUSER}" ]; then + if [ -f "${TOOLS}" ]; then + source "${TOOLS}" + importcreds "${CREDS}" else APIUSER="administrator:administrator" fi @@ -29,35 +29,35 @@ INPUT=(-T -) while getopts "f:hv" OPTION do - case $OPTION in - h) - usage - ;; - f) - INPUT=() - FILE_INPUT=(--data-binary @$OPTARG) - if [ ! -f "$OPTARG" ]; then - echo "No '$OPTARG' file found" - usage - fi - ;; - v) - VERBOSE="--verbose" - ;; - ?) - usage - ;; - esac + case ${OPTION} in + h) + usage + ;; + f) + INPUT=() + FILE_INPUT=(--data-binary @${OPTARG}) + if [ ! -f "${OPTARG}" ]; then + echo "No '${OPTARG}' file found" + usage + fi + ;; + v) + VERBOSE="--verbose" + ;; + ?) + usage + ;; + esac done shift $((OPTIND - 1)) URL="$1" -if [ -z "$URL" ] ; then +if [ -z "${URL}" ] ; then usage fi CTYPE=${2:-application/json} ${CURL} -i ${VERBOSE} -X PUT \ - -H 'Connection: close' -H 'Prefer: return=representation' \ - -H "Content-Type: $CTYPE" \ - --user "$APIUSER" --insecure "${FILE_INPUT[@]}" "$URL" "${INPUT[@]}" + -H 'Connection: close' -H 'Prefer: return=representation' \ + -H "Content-Type: ${CTYPE}" \ + --user "${APIUSER}" --insecure "${FILE_INPUT[@]}" "${URL}" "${INPUT[@]}"