tested incoming calls with 1,2,3 extensions
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 11 Jan 2010 22:37:01 +0000 (22:37 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 11 Jan 2010 22:37:01 +0000 (22:37 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@105 01035d8c-6547-0410-b346-abe4f91aad63

easy-asterisk-gui/set_ring.pl [deleted file]
easy-asterisk-gui/set_ring.sh

diff --git a/easy-asterisk-gui/set_ring.pl b/easy-asterisk-gui/set_ring.pl
deleted file mode 100755 (executable)
index ac95551..0000000
+++ /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 (<EXT>) { 
-    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 (<SIP>) { 
-    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 = "<img src=\"tick.png\" alt=\"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 = "<img src=\"cross.png\" alt=\"Not Connected\" />";
-        $tooltip_status = "onMouseOver=\"popUp(event,'ipphones_notconnected')\" onmouseout=\"popUp(event,'ipphones_notconnected')\"";
-        $comment="Available";
-       $tooltip_id = "iphones_$e";
-       print "<div id=\"$tooltip_id\" class=\"tip\"> Configure your IP phone with username/password $e/$e, SIP Server IP $ipaddress</div>";
-        $tooltip_ext = "onMouseOver=\"popUp(event,'$tooltip_id')\" onmouseout=\"popUp(event,'$tooltip_id')\"";
-       $tooltip_ip = "";
-    }
-    
-    if ($more == 1 || ($unconnected < 5)) {
-       print "<tr><td $tooltip_ext>$e</td><td></td><td $tooltip_ip>$comment</td><td $tooltip_status>$icon</td></tr>\n";
-    }
-}
-
-if ($more == 0) {
-    print '<tr><td><a href="ipphones.sh?more=1">More</a></td></tr>';
-}
-else {
-    print '<tr><td><a href="ipphones.sh">Less</a></td></tr>';
-}
-
-
index c2f112332f1495a45ce4c0a3f8fc27322d44812b..17d928d82d1002a57472719cceddacf9f4b91495 100644 (file)
@@ -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 '<meta http-equiv="REFRESH" content="0;url=http:login.sh">'
     echo "</head>"
     echo "</html>"
-    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 <<EOF
 <meta http-equiv="REFRESH" content="0;url=http:phones.sh">
 <body>
 Please wait a few seconds.....
+EOF
+#echo $QUERY_STRING "<br>"
+#echo "$QUERY_STRING" | sed -n "s/=on*//pg" | sed -n 's,_,/,pg'
+#echo "<br>"
+#echo $a
+
+cat <<EOF
 </body>
 </head>
 </html>