Consider absolute paths

This commit is contained in:
Gandalf 2021-03-04 20:17:30 +01:00
parent 5ca77e7479
commit 59309ba5ed
4 changed files with 11 additions and 7 deletions

View file

@ -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') 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" ]; if [ -z "$AUTH_TOKEN" ];
then then

View file

@ -1,4 +1,5 @@
#! /bin/bash #! /bin/bash
. authorization.sh BASEPATH=$(dirname $(realpath $0))
. getbalance.sh . $BASEPATH/authorization.sh
. $BASEPATH/getbalance.sh

7
fax.sh
View file

@ -8,7 +8,8 @@ then
where <recipient> has to be a german faxline number" where <recipient> has to be a german faxline number"
exit 1 exit 1
fi fi
. authorization.sh BASEPATH=$(dirname $(realpath $0))
. $BASEPATH/authorization.sh
#Prepare fax credentials: #Prepare fax credentials:
FILE=$1 FILE=$1
echo -n "Sending file ${FILE} " echo -n "Sending file ${FILE} "
@ -28,9 +29,9 @@ then
echo "Something went wrong, I didn't receive some fax id back." echo "Something went wrong, I didn't receive some fax id back."
else else
echo "Sipgate took your fax as sessionID $FAXID" echo "Sipgate took your fax as sessionID $FAXID"
echo "$FAXID" >> .fax_history echo "$FAXID" >> $BASEPATH/.fax_history
fi fi
#Check if fax request was accepted by sipgate #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' 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 #And show the account balance
. getbalance.sh . $BASEPATH/getbalance.sh

View file

@ -1,6 +1,7 @@
#! /bin/bash #! /bin/bash
. $(dirname $(realpath $0))/authorization.sh BASEPATH=$(dirname $(realpath $0))
. $BASEPATH/authorization.sh
while read LINE; while read LINE;
do 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) 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)