Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
Gandalf | 3e8962f01d | ||
Gandalf | 7c35a31aff | ||
Gandalf | de37f626c7 | ||
Gandalf | 9f96328b70 | ||
Gandalf | b615aaa634 |
23
callerid.sh
Executable file
23
callerid.sh
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
BASEPATH=$(dirname $(realpath $0))
|
||||||
|
#. $BASEPATH/authorization.sh
|
||||||
|
CALLER_ID="+49"
|
||||||
|
CALLER_ID_JSON=
|
||||||
|
case "$SPOOF" in
|
||||||
|
"1")
|
||||||
|
RANDOM=$(date +%s%N | cut -b10-19)
|
||||||
|
for (( x=1;x<=11;x++ ));
|
||||||
|
do
|
||||||
|
CALLER_ID="${CALLER_ID}$[$RANDOM % 10]"
|
||||||
|
done
|
||||||
|
CALLER_ID_JSON='{"value":"'${CALLER_ID}'"}'
|
||||||
|
;;
|
||||||
|
"-1")
|
||||||
|
CALLER_ID_JSON=$OLD_CALLER_ID_JSON
|
||||||
|
;;
|
||||||
|
"0")
|
||||||
|
CALLER_ID_JSON='{"value":"'${DEFAULT_CALLER_ID}'"}'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
OLD_CALLER_ID_JSON=$(curl --request GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $AUTH_TOKEN" "https://api.sipgate.com/v2/w0/faxlines/f0/callerid" -s)
|
||||||
|
REPLY=$(curl --request PUT --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $AUTH_TOKEN" --data ${CALLER_ID_JSON} "https://api.sipgate.com/v2/w0/faxlines/f0/callerid" -s)
|
||||||
|
#echo $OLD_CALLER_ID_JSON $CALLER_ID_JSON
|
15
fax.sh
15
fax.sh
|
@ -19,13 +19,14 @@ BASEPATH=$(dirname $(realpath $0))
|
||||||
|
|
||||||
#Parsing Parameters:
|
#Parsing Parameters:
|
||||||
unset $GETOPT_COMPATIBLE
|
unset $GETOPT_COMPATIBLE
|
||||||
ARGV=$(getopt -n "$0" -a -o "" -l "help,handle:" -- "$@")
|
ARGV=$(getopt -n "$0" -a -o "" -l "help,spoof-callerid,handle:" -- "$@")
|
||||||
if [ $? -ne 0 ]
|
if [ $? -ne 0 ]
|
||||||
then
|
then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
eval set -- "$ARGV"
|
eval set -- "$ARGV"
|
||||||
REC0=
|
REC0=
|
||||||
|
SPOOF=0
|
||||||
#Now we have $@ clean and tidy and begin parsing
|
#Now we have $@ clean and tidy and begin parsing
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
|
@ -41,6 +42,10 @@ do
|
||||||
REC0=$($LETTERHEAD_PATH/Adressen/address.sh -f $HAND 2>/dev/null | sed 's: ::g')
|
REC0=$($LETTERHEAD_PATH/Adressen/address.sh -f $HAND 2>/dev/null | sed 's: ::g')
|
||||||
shift
|
shift
|
||||||
shift ;;
|
shift ;;
|
||||||
|
"--spoof-callerid")
|
||||||
|
SPOOF=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
"--")
|
"--")
|
||||||
shift
|
shift
|
||||||
break ;;
|
break ;;
|
||||||
|
@ -56,6 +61,12 @@ then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
. $BASEPATH/authorization.sh
|
. $BASEPATH/authorization.sh
|
||||||
|
#Spoof CallerID if wanted
|
||||||
|
if [ $SPOOF -eq 1 ]
|
||||||
|
then
|
||||||
|
. $BASEPATH/callerid.sh
|
||||||
|
SPOOF=-1
|
||||||
|
fi
|
||||||
#Prepare fax credentials:
|
#Prepare fax credentials:
|
||||||
FILE=$1
|
FILE=$1
|
||||||
echo -n "Sending file ${FILE} "
|
echo -n "Sending file ${FILE} "
|
||||||
|
@ -109,5 +120,7 @@ else
|
||||||
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'
|
||||||
|
#Revert CallerID spoofing
|
||||||
|
. $BASEPATH/callerid.sh
|
||||||
#And show the account balance
|
#And show the account balance
|
||||||
. $BASEPATH/getbalance.sh
|
. $BASEPATH/getbalance.sh
|
||||||
|
|
|
@ -51,10 +51,13 @@ OUTFILE="$DATE-$ID-report.pdf"
|
||||||
if [ -z $FILE ]
|
if [ -z $FILE ]
|
||||||
then
|
then
|
||||||
echo "Fax seems not to be sent successfully (yet). No report available"
|
echo "Fax seems not to be sent successfully (yet). No report available"
|
||||||
read -p "Delete id from history anyways? (y/n) " DIN
|
if [ $DF = true ]
|
||||||
if [[ $DF = true && $DIN =~ [yYjJ] ]]
|
|
||||||
then
|
then
|
||||||
echo "$(grep -v "^$ID$" $BASEPATH/.fax_history)" > $BASEPATH/.fax_history
|
read -p "Delete id from history anyways? (y/n) " DIN
|
||||||
|
if [ $DIN =~ [yYjJ] ]
|
||||||
|
then
|
||||||
|
echo "$(grep -v "^$ID$" $BASEPATH/.fax_history)" > $BASEPATH/.fax_history
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#Add your sipgate username and password here:
|
#Add your sipgate username and password here:
|
||||||
SIPUSER=
|
SIPUSER=
|
||||||
SIPPWD=
|
SIPPWD=
|
||||||
|
#Add your default CallerID here:
|
||||||
|
DEFAULT_CALLER_ID=
|
||||||
#uncomment if you use Letterheads Address database
|
#uncomment if you use Letterheads Address database
|
||||||
#LETTERHEAD_PATH=
|
#LETTERHEAD_PATH=
|
||||||
|
|
Loading…
Reference in a new issue