From d98e7252262b63a2b3ef3ed56df0e3b731a8eb3a Mon Sep 17 00:00:00 2001 From: drowe67 Date: Mon, 11 Jan 2010 22:37:01 +0000 Subject: [PATCH] tested incoming calls with 1,2,3 extensions git-svn-id: https://svn.code.sf.net/p/freetel/code@105 01035d8c-6547-0410-b346-abe4f91aad63 --- easy-asterisk-gui/set_ring.pl | 92 ----------------------------------- easy-asterisk-gui/set_ring.sh | 24 +++++++-- 2 files changed, 19 insertions(+), 97 deletions(-) delete mode 100755 easy-asterisk-gui/set_ring.pl diff --git a/easy-asterisk-gui/set_ring.pl b/easy-asterisk-gui/set_ring.pl deleted file mode 100755 index ac955516..00000000 --- a/easy-asterisk-gui/set_ring.pl +++ /dev/null @@ -1,92 +0,0 @@ -#!/sbin/microperl -# set_ring.pl -# David Rowe 11 Jan 2010 -# -# modified extensions.conf to control which phones ring on -# incoming calls -# -# usage: ./set_ring tech1 tech2 tech3..... -# ./set_ring Zap/1 SIP/1 SIP/2 - -$ipaddress = $ARGV[0]; -$more = $ARGV[1]; - -# Slurp up SIP extension (Sip) data from extensions.conf - -my %ip = (); # ip extension keyed on sip.conf name - -open EXT, "/etc/asterisk/extensions.conf"; -while () { - if (/.*=>[ ]*([0-9]*),1.*SIP\/([0-9]*)\)/) { - $ip{$2} = $1; - #print "'$1' '$2' $ip{$2}\n"; - } -} -close EXT; - -my %sip = (); # SIP IP phone status keyed on sip.conf names - # if no entry we can't see IP phone device -my %voip = (); # SIP trunks status keyed on sip.conf names - # if no entry we can't see SIP trunk -my %ipad = (); # IP address of SIP device keyed on sip.conf names - -open SIP, "sipshowpeers.txt"; -while () { - if (/^([0-9]*)[\s\/].*(OK)/) { - $sip{$1} = $2; - #print "'$1' '$2' $sip{$1}\n"; - $e = $1; - if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) { - $ipad{$e} = $1; - #print "'$1'\n"; - } - } - if (/^(voip[0-9]*)[\s\/].*(OK)/) { - $voip{$1} = $2; - #print "'$1' '$2' $voip{$1}\n"; - $e = $1; - if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) { - $ipad{$e} = $1; - #print "'$1'\n"; - } - } -} - -close SIP; - -# print list of IP phones with connection status - -$unconnected = 0; -foreach $e (sort keys %ip) { - if ($sip{$e} eq "OK") { - $icon = "\"Connected\""; - $tooltip_status = "onMouseOver=\"popUp(event,'ipphones_connected')\" onmouseout=\"popUp(event,'ipphones_connected')\""; - $comment=$ipad{$e}; - $tooltip_ext = "onMouseOver=\"popUp(event,'phone_ext')\" onmouseout=\"popUp(event,'phone_ext')\""; - $tooltip_ip = "onMouseOver=\"popUp(event,'phone_ipphone_ip')\" onmouseout=\"popUp(event,'phone_ipphone_ip')\""; - $unconnected = 0; - } - else { - $unconnected = $unconnected + 1; - $icon = "\"Not"; - $tooltip_status = "onMouseOver=\"popUp(event,'ipphones_notconnected')\" onmouseout=\"popUp(event,'ipphones_notconnected')\""; - $comment="Available"; - $tooltip_id = "iphones_$e"; - print "
Configure your IP phone with username/password $e/$e, SIP Server IP $ipaddress
"; - $tooltip_ext = "onMouseOver=\"popUp(event,'$tooltip_id')\" onmouseout=\"popUp(event,'$tooltip_id')\""; - $tooltip_ip = ""; - } - - if ($more == 1 || ($unconnected < 5)) { - print "$e$comment$icon\n"; - } -} - -if ($more == 0) { - print 'More'; -} -else { - print 'Less'; -} - - diff --git a/easy-asterisk-gui/set_ring.sh b/easy-asterisk-gui/set_ring.sh index c2f11233..17d928d8 100644 --- a/easy-asterisk-gui/set_ring.sh +++ b/easy-asterisk-gui/set_ring.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -x # set_ring.sh # David Rowe 4 Jan 2010 # CGI to set which extensions ring on uncoming calls @@ -12,14 +12,21 @@ if [ $? -eq 1 ]; then echo '' echo "" echo "" - exit +# exit fi # extract extensions to ring and reload extensions.conf -args=`echo "$QUERY_STRING" | sed -n "s/=on*//pg" | sed -n 's,_,/,pg' | sed -n "s/&/\\\\&/p"` -sed -i "s_s,1,Dial(.*) ;; easy-asterisk_s,1,Dial($args) ;; easy-asterisk_" /etc/asterisk/extensions.conf -asterisk -rx "dialplan reload" >> /dev/null +a=`echo "$QUERY_STRING" | sed -n "s/=on*//pg" | sed -n 's,_,/,pg'` + +# escape & if present +echo "$a" | grep "&" >> /dev/null +if [ $? -eq 0 ]; then + a=`echo $a | sed -n "s/&/\\\\&/pg"` +fi + +sed -i "s_s,1,Dial(.*) ;; easy-asterisk_s,1,Dial($a) ;; easy-asterisk_" /etc/asterisk/extensions.conf +asterisk -rx "dialplan reload" 2>/dev/null 1 > /dev/null # bounce us back to Phones screen @@ -30,6 +37,13 @@ cat < Please wait a few seconds..... +EOF +#echo $QUERY_STRING "
" +#echo "$QUERY_STRING" | sed -n "s/=on*//pg" | sed -n 's,_,/,pg' +#echo "
" +#echo $a + +cat < -- 2.25.1