# 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
--- /dev/null
+<ol>
+<li>Connect the WAN port of the AT-530 to your LAN, it will boot and obtain an IP via DHCP.
+<li>Find the <strong>IP</strong> of the phone by pressing the <strong>Sysinfo</strong> button a few times.
+<li>Open another browser window. Go to the phones <strong>IP</strong>, for example <strong>http://192.168.1.160</strong>
+<li>Login to the phone using the username/password <strong>admin/admin</strong>.
+<li>Optional: set a static IP using the WAN menu (I like static IPs for SIP phones).
+<li>Go to the phone <strong>SIP Config</strong> menu.
+<li>Set <strong>Register Server Address</strong> to your Phone System IP Address.
+<li>Set <strong>Register Username</strong> to the phone number (e.g. 6011).
+<li>Also set </strong>Register Password</strong> to the phone number (e.g. 6011) and
+the </strong>Phone Number</strong> to the phone number (e.g. 6011).
+<li>Check the *Enable Register* box.
+<li>Then click on <strong>Apply</strong>.
+<li>Refresh this page to see if the phone is connected to your Phone system.
+</ol>
function localInit() {
- if (init_internet == "yes")
- $('internet').innerHTML = '<img src="tick.png" alt="tick" />';
- else
- $('internet').innerHTML = '<img src="cross.png" alt="tick" />';
}
--- /dev/null
+#!/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 (<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')\"";
+ }
+ 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>';
+}
+
+
# 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
<td valign="top">
- <form action="/cgi-bin/set_network.sh" onsubmit="return validate_form(this)" method="get">
<table align="right" width=600 border=0>
- <tr><td colspan="3" align="left" valign="top" ><h2>Dashboard</h2></td></tr>
- <tr onMouseOver="popUp(event,'network_internet')" onmouseout="popUp(event,'network_internet')">
- <td>Internet Connection:</td>
- <td><div id="internet" >
- <span style="margin-left: 4px;font-weight:bold"> </span></div></td>
- </tr>
- </table>
- </form>
+ <tr><td onMouseOver="popUp(event,'ipphones_ipphones')" onmouseout="popUp(event,'ipphones_ipphones')"
+ colspan="4" align="left" valign="top" ><h2>IP Phones</h2></td></tr>
+ <tr onMouseOver="popUp(event,'phone_ipaddress')" onmouseout="popUp(event,'phone_ipaddress')">
+ <td colspan="3">Phone System IP Address:</td>
+EOF
+echo "<td>$ipaddress</td></tr><td> </td><tr></tr>"
+
+ # use perl to construct list of IP phones for us
+ asterisk "-rx sip show peers" 2>/dev/null > sipshowpeers.txt
+ ./ipphones.pl $ipaddress $more
- </td>
+cat <<EOF
+ </table>
+ <h2> <br>How to Configure IP Phones</h2>
+ <h3>1. Atcom AT-530</h3>
+EOF
+cat at-530.html
+cat <<EOF
+ </td>
</tr>
</table>
echo ""
echo "<head>"
echo "<title>Easy Asterisk - Login</title>"
- echo '<meta http-equiv="REFRESH" content="0;url=http:dashboard.sh">'
+ echo '<meta http-equiv="REFRESH" content="0;url=http:phones.sh">'
echo "<body>"
echo "Please wait a few seconds....."
echo "</body>"
<td><a href="network.sh">Network</a></td>
</tr>
<tr onMouseOver="popUp(event,'ipphones_tip')" onmouseout="popUp(event,'ipphones_tip')">
- <td><a href="network.sh">IP Phones</a></td>
+ <td><a href="ipphones.sh">IP Phones</a></td>
</tr>
<tr onMouseOver="popUp(event,'phones_tip')" onmouseout="popUp(event,'phones_tip')">
<td><a href="phones.sh">Phones</a></td>
+++ /dev/null
-function localInit() {
- if (init_internet == "yes")
- $('internet').innerHTML = '<img src="tick.png" alt="tick" />';
- else
- $('internet').innerHTML = '<img src="cross.png" alt="tick" />';
-}
-
+++ /dev/null
-#!/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 (<EXT>) {
- 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 (<ZAP>) {
- 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 (<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 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 = "<img src=\"anphone.png\" alt=\"Analog Phone\" />";
- print "<tr><td $tooltip_ext>$analog{$a}</td><td $tooltip_anphone>Analog Phone</td><td $tooltip_port>Port $a</td><td>$icon</td></tr>\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 = "<img src=\"ipphone.png\" alt=\"IP Phone\" />";
- print "<tr><td $tooltip_ext>$s</td><td $tooltip_ipphone>IP Phone</td<td $tooltip_ipphone_ip>$ipad{$s}</td><td>$icon</td></tr>\n";
- }
-}
-
-$tool_tip = "onMouseOver=\"popUp(event,'phone_lines')\" onmouseout=\"popUp(event,'phone_lines')\"";
-
-print '<tr><td> </td></tr>';
-print "<tr $tool_tip><td colspan=\"4\" align=\"left\" valign=\"top\" ><h2>Phone Lines</h2></td></tr>
-";
-
-# 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 = "<img src=\"phoneline.jpg\" alt=\"Phone Line\" />";
- print "<tr><td>$analog{$a}</td><td $tooltip_phoneline>Analog</td><td $tooltip_port>Port $a</td><td>$icon</td></tr>\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 = "<img src=\"voipline.jpg\" alt=\"VOIP Line\" />";
- print "<tr><td>$s</td><td $tooltip_voipline>VOIP</td><td $tooltip_voipline_ip>$ipad{$s}</td><td>$icon</td></tr>\n";
- }
-}
-
+++ /dev/null
-#!/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
-<script src="prototype.js"></script>
-<link href="astman.css" media="all" rel="Stylesheet" type="text/css" />
-<script type="text/javascript" src="tooltip.js"></script>
-<link rel="stylesheet" href="tooltip.css" type="text/css" />
-EOF
-
-echo "<script>"
-echo 'var init_internet="'$internet'";'
-cat phone.js
-echo "</script>"
-
-cat << EOF
-<html>
-<title>Easy Asterisk - Phones</title>
-<body onload="localInit()">
-EOF
-
-cat tooltips.html
-echo '<table align="center" width=800>'
-cat banner.html
-echo " <tr>"
-cat menu.html
-cat <<EOF
-
- <td valign="top">
-
- <table align="right" width=600>
- <tr>
- <td onMouseOver="popUp(event,'phone_system')" onmouseout="popUp(event,'phone_system')" colspan="3" align="left" valign="top"><h2>Phone System</h2></td>
- <td onMouseOver="popUp(event,'phone_addipphone')" onmouseout="popUp(event,'phone_addipphone')"><a href="addipphone.sh">Add IP Phone</a></td>
- </tr>
- <tr onMouseOver="popUp(event,'network_internet')" onmouseout="popUp(event,'network_internet')">
- <td colspan="3">Internet Connection:</td>
- <td><div id="internet" > </div></td>
- </tr>
- <tr onMouseOver="popUp(event,'phone_ipaddress')" onmouseout="popUp(event,'phone_ipaddress')">
- <td colspan="3">Phone System IP Address:</td>
-EOF
-echo "<td>$ipaddress</td>"
-cat <<EOF
- </tr>
- <tr><td> </td></tr>
- <tr onMouseOver="popUp(event,'phone_phones')" onmouseout="popUp(event,'phone_phones')">
- <td colspan="4" align="left" valign="top" ><h2>Phones</h2></td>
- </tr>
-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<<EOF
- </table>
-
- </td>
-
- </tr>
-
-</table>
-</body>
-</html>
-EOF
-
--- /dev/null
+function localInit() {
+ if (init_internet == "yes")
+ $('internet').innerHTML = '<img src="tick.png" alt="tick" />';
+ else
+ $('internet').innerHTML = '<img src="cross.png" alt="tick" />';
+}
+
--- /dev/null
+#!/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 (<EXT>) {
+ 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 (<ZAP>) {
+ 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 (<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 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 = "<img src=\"anphone.png\" alt=\"Analog Phone\" />";
+ print "<tr><td $tooltip_ext>$analog{$a}</td><td $tooltip_anphone>Analog Phone</td><td $tooltip_port>Port $a</td><td>$icon</td></tr>\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 = "<img src=\"ipphone.png\" alt=\"IP Phone\" />";
+ print "<tr><td $tooltip_ext>$s</td><td $tooltip_ipphone>IP Phone</td<td $tooltip_ipphone_ip>$ipad{$s}</td><td>$icon</td></tr>\n";
+ }
+}
+
+$tool_tip = "onMouseOver=\"popUp(event,'phone_lines')\" onmouseout=\"popUp(event,'phone_lines')\"";
+
+print '<tr><td> </td></tr>';
+print "<tr $tool_tip><td colspan=\"4\" align=\"left\" valign=\"top\" ><h2>Phone Lines</h2></td></tr>
+";
+
+# 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 = "<img src=\"phoneline.jpg\" alt=\"Phone Line\" />";
+ print "<tr><td>$analog{$a}</td><td $tooltip_phoneline>Analog</td><td $tooltip_port>Port $a</td><td>$icon</td></tr>\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 = "<img src=\"voipline.jpg\" alt=\"VOIP Line\" />";
+ print "<tr><td>$s</td><td $tooltip_voipline>VOIP</td><td $tooltip_voipline_ip>$ipad{$s}</td><td>$icon</td></tr>\n";
+ }
+}
+
--- /dev/null
+#!/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
+<script src="prototype.js"></script>
+<link href="astman.css" media="all" rel="Stylesheet" type="text/css" />
+<script type="text/javascript" src="tooltip.js"></script>
+<link rel="stylesheet" href="tooltip.css" type="text/css" />
+EOF
+
+echo "<script>"
+echo 'var init_internet="'$internet'";'
+cat phones.js
+echo "</script>"
+
+cat << EOF
+<html>
+<title>Easy Asterisk - Phones</title>
+<body onload="localInit()">
+EOF
+
+cat tooltips.html
+echo '<table align="center" width=800>'
+cat banner.html
+echo " <tr>"
+cat menu.html
+cat <<EOF
+
+ <td valign="top">
+
+ <table align="right" width=600>
+ <tr>
+ <td onMouseOver="popUp(event,'phone_system')" onmouseout="popUp(event,'phone_system')" colspan="4" align="left" valign="top"><h2>Phone System</h2></td>
+ </tr>
+ <tr onMouseOver="popUp(event,'network_internet')" onmouseout="popUp(event,'network_internet')">
+ <td colspan="3">Internet Connection:</td>
+ <td><div id="internet" > </div></td>
+ </tr>
+ <tr onMouseOver="popUp(event,'phone_ipaddress')" onmouseout="popUp(event,'phone_ipaddress')">
+ <td colspan="3">Phone System IP Address:</td>
+EOF
+echo "<td>$ipaddress</td>"
+cat <<EOF
+ </tr>
+ <tr><td> </td></tr>
+ <tr>
+ <td onMouseOver="popUp(event,'phone_phones')" onmouseout="popUp(event,'phone_phones')"
+ colspan="3" align="left" valign="top" ><h2>Phones</h2></td>
+ <td onMouseOver="popUp(event,'phone_addipphone')" onmouseout="popUp(event,'phone_addipphone')">
+ <a href="addipphone.sh">Add IP Phone</a></td>
+ </tr>
+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<<EOF
+ </table>
+
+ </td>
+
+ </tr>
+
+</table>
+</body>
+</html>
+EOF
+
<div id="phone_addipphone" class="tip">
Instructions and help on adding a new IP phone</div>
+
+<div id="ipphones_ipphones" class="tip">
+ List of possible IP phones. Choose a free one
+ (cross) for a new phone. Refresh this page tp
+ update</div>
+
+<div id="ipphones_connected" class="tip">
+ The IP phone is connected to your phone system and ready to use</div>
+
+<div id="ipphones_notconnected" class="tip">
+ No IP phone is connected. This could be
+ because no IP phone is present, or the IP
+ phone has not been set up.</div>
+