From: drowe67 Date: Wed, 6 Jan 2010 03:55:11 +0000 (+0000) Subject: first pass at working ip phones page X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=443f3991f254ef1e65c0f133155776a2a66d0fdb;p=freetel-svn-tracking.git first pass at working ip phones page git-svn-id: https://svn.code.sf.net/p/freetel/code@98 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/easy-asterisk-gui/Makefile b/easy-asterisk-gui/Makefile index 544598a8..2543554b 100644 --- a/easy-asterisk-gui/Makefile +++ b/easy-asterisk-gui/Makefile @@ -9,5 +9,5 @@ TESTIP=192.168.1.150 # rcp index.html root@$(TESTIP):/var/lib/asterisk/static-http/ test: - rcp ipphones.sh ipphones.js voipline.jpg anphone.png phoneline.jpg ipphone.png phone.pl tooltips.html phone.sh phone.js tick.png cross.png banner.html menu.html check_loggedin.sh logout.sh login.sh network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin + rcp at-530.html ipphones.pl ipphones.sh ipphones.js voipline.jpg anphone.png phoneline.jpg ipphone.png phones.pl tooltips.html phones.sh phones.js tick.png cross.png banner.html menu.html check_loggedin.sh logout.sh login.sh network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin rcp sip.conf extensions.conf root@$(TESTIP):/etc/asterisk diff --git a/easy-asterisk-gui/at-530.html b/easy-asterisk-gui/at-530.html new file mode 100644 index 00000000..ab94e3d7 --- /dev/null +++ b/easy-asterisk-gui/at-530.html @@ -0,0 +1,15 @@ +
    +
  1. Connect the WAN port of the AT-530 to your LAN, it will boot and obtain an IP via DHCP. +
  2. Find the IP of the phone by pressing the Sysinfo button a few times. +
  3. Open another browser window. Go to the phones IP, for example http://192.168.1.160 +
  4. Login to the phone using the username/password admin/admin. +
  5. Optional: set a static IP using the WAN menu (I like static IPs for SIP phones). +
  6. Go to the phone SIP Config menu. +
  7. Set Register Server Address to your Phone System IP Address. +
  8. Set Register Username to the phone number (e.g. 6011). +
  9. Also set Register Password to the phone number (e.g. 6011) and +the Phone Number to the phone number (e.g. 6011). +
  10. Check the *Enable Register* box. +
  11. Then click on Apply. +
  12. Refresh this page to see if the phone is connected to your Phone system. +
diff --git a/easy-asterisk-gui/ipphones.js b/easy-asterisk-gui/ipphones.js index 74d6eaf1..9c50ceac 100644 --- a/easy-asterisk-gui/ipphones.js +++ b/easy-asterisk-gui/ipphones.js @@ -1,7 +1,3 @@ function localInit() { - if (init_internet == "yes") - $('internet').innerHTML = 'tick'; - else - $('internet').innerHTML = 'tick'; } diff --git a/easy-asterisk-gui/ipphones.pl b/easy-asterisk-gui/ipphones.pl new file mode 100755 index 00000000..cdd93d19 --- /dev/null +++ b/easy-asterisk-gui/ipphones.pl @@ -0,0 +1,87 @@ +#!/sbin/microperl +# ipphones.pl +# David Rowe 6 Jan 2010 +# +# Test processing for the ipphones screen + +$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')\""; + } + 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/ipphones.sh b/easy-asterisk-gui/ipphones.sh index 6f63dab1..fccfb08a 100644 --- a/easy-asterisk-gui/ipphones.sh +++ b/easy-asterisk-gui/ipphones.sh @@ -3,6 +3,9 @@ # David Rowe 6 Jan 2010 # Dashboard screen for Easy Asterisk GUI +more=`echo "$QUERY_STRING" | grep -oe "more=[^&?]*" | sed -n "s/more=//p"` +ipaddress=`ifconfig eth0 | sed -n 's/.*inet addr:\(.*\) Bcast.*/\1/p'` + # Construct the web page ------------------------------- sh check_loggedin.sh @@ -34,19 +37,27 @@ cat < -
- - - - - -

Dashboard

Internet Connection:
-  
-
+

IP Phones

+ + Phone System IP Address: +EOF +echo "$ipaddress " + + # use perl to construct list of IP phones for us + asterisk "-rx sip show peers" 2>/dev/null > sipshowpeers.txt + ./ipphones.pl $ipaddress $more - +cat < +

 
How to Configure IP Phones

+

1. Atcom AT-530

+EOF +cat at-530.html +cat < diff --git a/easy-asterisk-gui/login.sh b/easy-asterisk-gui/login.sh index afe42e3f..3213d685 100644 --- a/easy-asterisk-gui/login.sh +++ b/easy-asterisk-gui/login.sh @@ -42,7 +42,7 @@ else echo "" echo "" echo "Easy Asterisk - Login" - echo '' + echo '' echo "" echo "Please wait a few seconds....." echo "" diff --git a/easy-asterisk-gui/menu.html b/easy-asterisk-gui/menu.html index c4bc9f74..d56b597d 100644 --- a/easy-asterisk-gui/menu.html +++ b/easy-asterisk-gui/menu.html @@ -12,7 +12,7 @@ Network - IP Phones + IP Phones Phones diff --git a/easy-asterisk-gui/phone.js b/easy-asterisk-gui/phone.js deleted file mode 100644 index 74d6eaf1..00000000 --- a/easy-asterisk-gui/phone.js +++ /dev/null @@ -1,7 +0,0 @@ -function localInit() { - if (init_internet == "yes") - $('internet').innerHTML = 'tick'; - else - $('internet').innerHTML = 'tick'; -} - diff --git a/easy-asterisk-gui/phone.pl b/easy-asterisk-gui/phone.pl deleted file mode 100755 index 93157bbc..00000000 --- a/easy-asterisk-gui/phone.pl +++ /dev/null @@ -1,129 +0,0 @@ -#!/sbin/microperl -# phone.pl -# David Rowe 5 Jan 2010 -# -# Extracts the phone extension infor from /etc/asterisk/extensions.conf -# and generate html. Perl used as faster than equivalent shell script - -$tool_tip = "onMouseOver=\"popUp(event,'network_internet')\" onmouseout=\"popUp(event,'network_internet')\""; - -my %analog = (); # analog extension keyed on zap port - -open EXT, "/etc/asterisk/extensions.conf"; -while () { - if (/.*=>[ ]*([0-9]*),1.*Zap\/([0-9]*)\)/) { - $analog{$2} = $1; - #print "'$1' '$2' $analog{$2}\n"; - } -} -close EXT; - -my %zap = (); # zaptel port type keyed on zap port - # (fxs/fxo or no entry if not live) -open ZAP, "/etc/zaptel.conf"; -while () { - if (/fxoks=([0-9]*)/) { - $zap{$1} = "fxs"; - } - if (/fxsks=([0-9]*)/) { - $zap{$1} = "fxo"; - } -} -close ZAP; - -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 analog phones - -$tooltip_anphone = "onMouseOver=\"popUp(event,'phone_anphone')\" onmouseout=\"popUp(event,'phone_anphone')\""; -$tooltip_ext = "onMouseOver=\"popUp(event,'phone_ext')\" onmouseout=\"popUp(event,'phone_ext')\""; -$tooltip_port = "onMouseOver=\"popUp(event,'phone_port_phone')\" onmouseout=\"popUp(event,'phone_port_phone')\""; - -foreach $a (sort keys %analog) { - if ($zap{$a} eq "fxs") { - $icon = "\"Analog"; - print "$analog{$a}Analog PhonePort $a$icon\n"; - } -} - -# print list of IP phones - -$tooltip_ipphone = "onMouseOver=\"popUp(event,'phone_ipphone')\" onmouseout=\"popUp(event,'phone_ipphone')\""; -$tooltip_ipphone_ip = "onMouseOver=\"popUp(event,'phone_ipphone_ip')\" onmouseout=\"popUp(event,'phone_ipphone_ip')\""; - -foreach $s (sort keys %sip) { - if ($sip{$s} eq "OK") { - $icon = "\"IP"; - print "$sIP Phone$ipad{$s}$icon\n"; - } -} - -$tool_tip = "onMouseOver=\"popUp(event,'phone_lines')\" onmouseout=\"popUp(event,'phone_lines')\""; - -print ' '; -print "

Phone Lines

-"; - -# print list of analog phone lines - -$tooltip_phoneline = "onMouseOver=\"popUp(event,'phone_phoneline')\" onmouseout=\"popUp(event,'phone_phoneline')\""; -$tooltip_port = "onMouseOver=\"popUp(event,'phone_port_line')\" onmouseout=\"popUp(event,'phone_port_line')\""; - -foreach $a (sort keys %analog) { - if ($zap{$a} eq "fxo") { - $icon = "\"Phone"; - print "$analog{$a}AnalogPort $a$icon\n"; - } -} - -# print list of SIP VOIP trunks - -$tooltip_voipline = "onMouseOver=\"popUp(event,'phone_voipline')\" onmouseout=\"popUp(event,'phone_voipline')\""; -$tooltip_voipline_ip = "onMouseOver=\"popUp(event,'phone_voipline_ip')\" onmouseout=\"popUp(event,'phone_voipline_ip')\""; - -foreach $s (sort keys %voip) { - if ($voip{$s} eq "OK") { - $icon = "\"VOIP"; - print "$sVOIP$ipad{$s}$icon\n"; - } -} - diff --git a/easy-asterisk-gui/phone.sh b/easy-asterisk-gui/phone.sh deleted file mode 100644 index 7a36ccb3..00000000 --- a/easy-asterisk-gui/phone.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh -x -# phone.sh -# David Rowe 4 Jan 2010 -# CGI for Easy Asterisk phones GUI - -# See if we have Internet connectivity, first check dns as time outs can be very slow - -dns=`cat /etc/resolv.conf | awk '/^nameserver/ {print $2}'` -dns_packet_loss=`ping $dns -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'` -internet="no"; -if [ $dns_packet_loss == "0" ]; then - packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'` - if [ $packet_loss == "0" ]; then - internet="yes"; - fi -fi - -ipaddress=`ifconfig eth0 | sed -n 's/.*inet addr:\(.*\) Bcast.*/\1/p'` - -# Construct the web page ------------------------------- - -sh check_loggedin.sh - -cat < - - - -EOF - -echo "" - -cat << EOF - -Easy Asterisk - Phones - -EOF - -cat tooltips.html -echo '' -cat banner.html -echo " " -cat menu.html -cat < - -
- - - - - - - - - - -EOF -echo "" -cat < - - - - -EOF - -# use perl to construct list of phones and phone lines for us -asterisk "-rx sip show peers" 2>/dev/null > sipshowpeers.txt -./phone.pl - -cat< - - - - - -

Phone System

Add IP Phone
Internet Connection:
 
Phone System IP Address:$ipaddress
 

Phones

- - -EOF - diff --git a/easy-asterisk-gui/phones.js b/easy-asterisk-gui/phones.js new file mode 100644 index 00000000..74d6eaf1 --- /dev/null +++ b/easy-asterisk-gui/phones.js @@ -0,0 +1,7 @@ +function localInit() { + if (init_internet == "yes") + $('internet').innerHTML = 'tick'; + else + $('internet').innerHTML = 'tick'; +} + diff --git a/easy-asterisk-gui/phones.pl b/easy-asterisk-gui/phones.pl new file mode 100755 index 00000000..518b40f2 --- /dev/null +++ b/easy-asterisk-gui/phones.pl @@ -0,0 +1,134 @@ +#!/sbin/microperl +# phones.pl +# David Rowe 5 Jan 2010 +# +# Test processing for the phones screen. + +$tool_tip = "onMouseOver=\"popUp(event,'network_internet')\" onmouseout=\"popUp(event,'network_internet')\""; + +# Slurp up analog port (Zap) data from extensions.conf + +my %analog = (); # analog extension keyed on zap port + +open EXT, "/etc/asterisk/extensions.conf"; +while () { + if (/.*=>[ ]*([0-9]*),1.*Zap\/([0-9]*)\)/) { + $analog{$2} = $1; + #print "'$1' '$2' $analog{$2}\n"; + } +} +close EXT; + +# Slurp up data on installed zaptel ports from /etc/zaptel.conf + +my %zap = (); # zaptel port type keyed on zap port + # (fxs/fxo or no entry if not live) +open ZAP, "/etc/zaptel.conf"; +while () { + if (/fxoks=([0-9]*)/) { + $zap{$1} = "fxs"; + } + if (/fxsks=([0-9]*)/) { + $zap{$1} = "fxo"; + } +} +close ZAP; + +# 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 analog phones + +$tooltip_anphone = "onMouseOver=\"popUp(event,'phone_anphone')\" onmouseout=\"popUp(event,'phone_anphone')\""; +$tooltip_ext = "onMouseOver=\"popUp(event,'phone_ext')\" onmouseout=\"popUp(event,'phone_ext')\""; +$tooltip_port = "onMouseOver=\"popUp(event,'phone_port_phone')\" onmouseout=\"popUp(event,'phone_port_phone')\""; + +foreach $a (sort keys %analog) { + if ($zap{$a} eq "fxs") { + $icon = "\"Analog"; + print "$analog{$a}Analog PhonePort $a$icon\n"; + } +} + +# print list of IP phones + +$tooltip_ipphone = "onMouseOver=\"popUp(event,'phone_ipphone')\" onmouseout=\"popUp(event,'phone_ipphone')\""; +$tooltip_ipphone_ip = "onMouseOver=\"popUp(event,'phone_ipphone_ip')\" onmouseout=\"popUp(event,'phone_ipphone_ip')\""; + +foreach $s (sort keys %sip) { + if ($sip{$s} eq "OK") { + $icon = "\"IP"; + print "$sIP Phone$ipad{$s}$icon\n"; + } +} + +$tool_tip = "onMouseOver=\"popUp(event,'phone_lines')\" onmouseout=\"popUp(event,'phone_lines')\""; + +print ' '; +print "

Phone Lines

+"; + +# print list of analog phone lines + +$tooltip_phoneline = "onMouseOver=\"popUp(event,'phone_phoneline')\" onmouseout=\"popUp(event,'phone_phoneline')\""; +$tooltip_port = "onMouseOver=\"popUp(event,'phone_port_line')\" onmouseout=\"popUp(event,'phone_port_line')\""; + +foreach $a (sort keys %analog) { + if ($zap{$a} eq "fxo") { + $icon = "\"Phone"; + print "$analog{$a}AnalogPort $a$icon\n"; + } +} + +# print list of SIP VOIP trunks + +$tooltip_voipline = "onMouseOver=\"popUp(event,'phone_voipline')\" onmouseout=\"popUp(event,'phone_voipline')\""; +$tooltip_voipline_ip = "onMouseOver=\"popUp(event,'phone_voipline_ip')\" onmouseout=\"popUp(event,'phone_voipline_ip')\""; + +foreach $s (sort keys %voip) { + if ($voip{$s} eq "OK") { + $icon = "\"VOIP"; + print "$sVOIP$ipad{$s}$icon\n"; + } +} + diff --git a/easy-asterisk-gui/phones.sh b/easy-asterisk-gui/phones.sh new file mode 100644 index 00000000..98bec0c4 --- /dev/null +++ b/easy-asterisk-gui/phones.sh @@ -0,0 +1,89 @@ +#!/bin/sh -x +# phones.sh +# David Rowe 4 Jan 2010 +# Phones screen for Easy Asterisk GUI + +# See if we have Internet connectivity, first check dns as time outs can be very slow + +dns=`cat /etc/resolv.conf | awk '/^nameserver/ {print $2}'` +dns_packet_loss=`ping $dns -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'` +internet="no"; +if [ $dns_packet_loss == "0" ]; then + packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'` + if [ $packet_loss == "0" ]; then + internet="yes"; + fi +fi + +ipaddress=`ifconfig eth0 | sed -n 's/.*inet addr:\(.*\) Bcast.*/\1/p'` + +# Construct the web page ------------------------------- + +sh check_loggedin.sh + +cat < + + + +EOF + +echo "" + +cat << EOF + +Easy Asterisk - Phones + +EOF + +cat tooltips.html +echo '' +cat banner.html +echo " " +cat menu.html +cat < + +
+ + + + + + + + + +EOF +echo "" +cat < + + + + + +EOF + +# use perl to construct list of phones and phone lines for us +asterisk "-rx sip show peers" 2>/dev/null > sipshowpeers.txt +./phones.pl + +cat< + + + + + +

Phone System

Internet Connection:
 
Phone System IP Address:$ipaddress
 

Phones

+ Add IP Phone
+ + +EOF + diff --git a/easy-asterisk-gui/tooltips.html b/easy-asterisk-gui/tooltips.html index 6b9963cb..20d90e12 100644 --- a/easy-asterisk-gui/tooltips.html +++ b/easy-asterisk-gui/tooltips.html @@ -68,3 +68,17 @@
Instructions and help on adding a new IP phone
+ +
+ List of possible IP phones. Choose a free one + (cross) for a new phone. Refresh this page tp + update
+ +
+ The IP phone is connected to your phone system and ready to use
+ +
+ No IP phone is connected. This could be + because no IP phone is present, or the IP + phone has not been set up.
+