calltoj/action-handler-callto.sh

44 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
action=$@
gateway=172.20.21.254
snom_webadmin_user=admin
snom_webadmin_pw=x7eff15
hostname_snom=snom765-901777.getcom.de
echo "_______________________________________________">> /tmp/action-handler-last-calls.log
date +%Y-%m-%d" "%H:%m:%S >> /tmp/action-handler-last-calls.log
number="$(echo $action | sed -e 's/callto://' | sed -e 's/tel://' | sed -e 's/sip://' | sed -e "s/+49/0/" | sed -e "s/-//g" | sed -e "s/%20//g")"
current_gateway="$(route -n | grep ^0.0.0.0 | awk '{print $2}' | sort -u)"
if [ -z $number ]
then
echo "Usage: `basename $0` [PHONE NUMBER]"
exit 0
fi
# precondition:
# user.prefs of Firefox including:
#
# network.http.phishy-userpass-length 5
# network.protocol-handler.expose.callto true
# network.protocol-handler.expose.tel false
# network.protocol-handler.external.callto true
# network.protocol-handler.warn-external.callto false
# network.protocol-handler.app.callto /usr/local/bin/action-handler-callto.sh
# network.protocol-handler.app.tel /usr/local/bin/action-handler-callto.sh
if [ "$gateway" = "$current_gateway" ]
then
echo "@home: using Snom phone to dial number: $number (action=$action)" | tee -a /tmp/action-handler-last-calls.log
lynx --source -auth=$snom_webadmin_user:$snom_webadmin_pw "http://$hostname_snom/command.htm?number=$number&outgoing_uri=URI" >/tmp/action-handler-last-uri.html
else
echo "@outside: using linphone to dial number: $number (action=$action)" | tee -a /tmp/action-handler-last-calls.log
/usr/bin/linphone -c "$number" \&\&
fi
exit 0