Compare commits

...

5 Commits

Author SHA1 Message Date
Gandalf 3e8962f01d Small bugfixes 2022-02-05 19:15:42 +01:00
Gandalf 7c35a31aff merge/rebase changes in faxreport.sh from master 2022-02-05 19:04:26 +01:00
Gandalf de37f626c7 Kleine Korrekturen 2022-02-05 18:36:42 +01:00
Gandalf 9f96328b70 randomisierte Telefonnummer 2022-02-05 18:30:52 +01:00
Gandalf b615aaa634 Spoofing caller id.
Can only test in production, which means untested as of now.
2022-02-05 18:05:49 +01:00
4 changed files with 45 additions and 4 deletions

23
callerid.sh Executable file
View 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
View File

@ -19,13 +19,14 @@ BASEPATH=$(dirname $(realpath $0))
#Parsing Parameters:
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 ]
then
usage
fi
eval set -- "$ARGV"
REC0=
SPOOF=0
#Now we have $@ clean and tidy and begin parsing
while :
do
@ -41,6 +42,10 @@ do
REC0=$($LETTERHEAD_PATH/Adressen/address.sh -f $HAND 2>/dev/null | sed 's: ::g')
shift
shift ;;
"--spoof-callerid")
SPOOF=1
shift
;;
"--")
shift
break ;;
@ -56,6 +61,12 @@ then
usage
fi
. $BASEPATH/authorization.sh
#Spoof CallerID if wanted
if [ $SPOOF -eq 1 ]
then
. $BASEPATH/callerid.sh
SPOOF=-1
fi
#Prepare fax credentials:
FILE=$1
echo -n "Sending file ${FILE} "
@ -109,5 +120,7 @@ else
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'
#Revert CallerID spoofing
. $BASEPATH/callerid.sh
#And show the account balance
. $BASEPATH/getbalance.sh

View File

@ -51,10 +51,13 @@ OUTFILE="$DATE-$ID-report.pdf"
if [ -z $FILE ]
then
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 && $DIN =~ [yYjJ] ]]
if [ $DF = true ]
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
exit 1
fi

View File

@ -1,5 +1,7 @@
#Add your sipgate username and password here:
SIPUSER=
SIPPWD=
#Add your default CallerID here:
DEFAULT_CALLER_ID=
#uncomment if you use Letterheads Address database
#LETTERHEAD_PATH=