From 59309ba5ed24b3e6939c3edfaaead42dba50eda7 Mon Sep 17 00:00:00 2001 From: Gandalf Date: Thu, 4 Mar 2021 20:17:30 +0100 Subject: [PATCH] Consider absolute paths --- authorization.sh | 3 ++- balance.sh | 5 +++-- fax.sh | 7 ++++--- status.sh | 3 ++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/authorization.sh b/authorization.sh index eac873c..c34dbbb 100755 --- a/authorization.sh +++ b/authorization.sh @@ -1,4 +1,5 @@ -. login_credentials.sh +BASEPATH=$(dirname $(realpath $0)) +. $BASEPATH/login_credentials.sh AUTH_TOKEN=$(echo $(curl --request POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --data-urlencode client_id=sipgate-app-web --data-urlencode grant_type=password --data-urlencode username=$SIPUSER --data-urlencode password=$SIPPWD https://api.sipgate.com/login/sipgate-apps/protocol/openid-connect/token -s | jq '.access_token') | sed 's/\"//g') if [ -z "$AUTH_TOKEN" ]; then diff --git a/balance.sh b/balance.sh index 6cca277..a9c8ba0 100755 --- a/balance.sh +++ b/balance.sh @@ -1,4 +1,5 @@ #! /bin/bash -. authorization.sh -. getbalance.sh +BASEPATH=$(dirname $(realpath $0)) +. $BASEPATH/authorization.sh +. $BASEPATH/getbalance.sh diff --git a/fax.sh b/fax.sh index 0539f8c..72cfef4 100755 --- a/fax.sh +++ b/fax.sh @@ -8,7 +8,8 @@ then where has to be a german faxline number" exit 1 fi -. authorization.sh +BASEPATH=$(dirname $(realpath $0)) +. $BASEPATH/authorization.sh #Prepare fax credentials: FILE=$1 echo -n "Sending file ${FILE} " @@ -28,9 +29,9 @@ then echo "Something went wrong, I didn't receive some fax id back." else echo "Sipgate took your fax as sessionID $FAXID" - echo "$FAXID" >> .fax_history + echo "$FAXID" >> $BASEPATH/.fax_history fi #Check if fax request was accepted by sipgate curl --request GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $AUTH_TOKEN" "https://api.sipgate.com/v2/history/$FAXID" -s | jq '.faxStatusType' #And show the account balance -. getbalance.sh +. $BASEPATH/getbalance.sh diff --git a/status.sh b/status.sh index 88604d3..ccc774e 100755 --- a/status.sh +++ b/status.sh @@ -1,6 +1,7 @@ #! /bin/bash -. $(dirname $(realpath $0))/authorization.sh +BASEPATH=$(dirname $(realpath $0)) +. $BASEPATH/authorization.sh while read LINE; do JSON=$(curl --request GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $AUTH_TOKEN" "https://api.sipgate.com/v2/history/$LINE" -s)