# rcp index.html root@$(TESTIP):/var/lib/asterisk/static-http/
test:
- rcp banner.html menu.html check_loggedin.sh logout.sh login.sh dashboard.sh dashboard.js network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin
+ rcp check_network.sh tick.png cross.png banner.html menu.html check_loggedin.sh logout.sh login.sh dashboard.sh dashboard.js network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin
function localInit() {
- $('internet').innerHTML = init_internet;
+ if (init_internet == "yes")
+ $('internet').innerHTML = '<img src="tick.png" alt="tick" />';
+ else
+ $('internet').innerHTML = '<img src="cross.png" alt="tick" />';
}
# David Rowe 4 Jan 2010
# CGI for Easy Asterisk dashboard GUI
-# See if we have Internet connectivity
+# See if we have Internet connectivity, unlike network.sh we don't check dns first
+internet="no";
packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
if [ $packet_loss == "0" ]; then
- internet="Good";
-else
- internet="Not Available";
+ internet="yes";
fi
# Construct the web page -------------------------------
<form action="/cgi-bin/set_network.sh" onsubmit="return validate_form(this)" method="get">
<table align="right" width=600>
<tr>
- <tr><td colspan="2" align="left"><h2>Dashboard</h2></td>
+ <tr><td colspan="2" align="left" valign="top" ><h2>Dashboard</h2></td>
<tr onMouseOver="popUp(event,'t1')" onmouseout="popUp(event,'t1')">
<td>Internet Connection:</td>
<td><div id="internet" >
+ <div id="admin_tip" class="tip">Change your password</div>
<div id="dashboard_tip" class="tip">Monitor the status of your phone system</div>
- <div id="network_tip" class="tip">Set up the network and connect to the Internet</div>
+ <div id="network_tip" class="tip">Connect the phone system to your network and the Internet</div>
+ <div id="phone_tip" class="tip">Set up your phones and phone calls</div>
<td valign="top" >
<table align="right" width=200>
<tr><td><h2> </h2></td></tr>
+ <tr onMouseOver="popUp(event,'admin_tip')" onmouseout="popUp(event,'admin_tip')">
+ <td><a href="admin.sh">Admin</a></td>
+ </tr>
<tr onMouseOver="popUp(event,'dashboard_tip')" onmouseout="popUp(event,'dashboard_tip')">
<td><a href="dashboard.sh">Dashboard</a></td>
</tr>
<tr onMouseOver="popUp(event,'network_tip')" onmouseout="popUp(event,'network_tip')">
<td><a href="network.sh">Network</a></td>
</tr>
+ <tr onMouseOver="popUp(event,'phone_tip')" onmouseout="popUp(event,'phone_tip')">
+ <td><a href="phone.sh">Phones</a></td>
+ </tr>
<tr>
<td><a href="logout.sh">Logout</a></td>
</tr>
$('netmask').value = init_netmask;
$('gateway').value = init_gateway;
$('dns').value = init_dns;
- $('internet').innerHTML = init_internet;
+ $('backdoor').value = init_backdoor;
+ if (init_internet == "yes")
+ $('internet').innerHTML = '<img src="tick.png" alt="tick" />';
+ else
+ $('internet').innerHTML = '<img src="cross.png" alt="tick" />';
+
}
function validate_form(form)
-#!/bin/sh
+#!/bin/sh -x
# network.sh
# David Rowe 4 Jan 2010
# CGI for Easy Asterisk network GUI
dns=`sed -n 's/DNS="\(.*\)"/\1/p' /etc/init.d/network-static`
fi
-# See if we have Internet connectivity
+if [ -f /etc/rc.d/S05network-backdoor ]; then
+ backdoor=`sed -n 's/IPADDRESS="\(.*\)"/\1/p' /etc/init.d/network-backdoor`
+fi
+
+# See if we have Internet connectivity, first check dns as time outs can be very slow
-packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
-if [ $packet_loss == "0" ]; then
- internet="Good";
-else
- internet="Not Available";
+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
# Construct the web page -------------------------------
echo 'var init_netmask="'$netmask'";'
echo 'var init_gateway="'$gateway'";'
echo 'var init_dns="'$dns'";'
+echo 'var init_backdoor="'$backdoor'";'
echo 'var init_internet="'$internet'";'
cat network.js
echo "</script>"
<html>
<title>Easy Asterisk - Network</title>
<body onload="localInit()">
-<div id="t1" class="tip">Tells you if I can reach the Internet. If not "Good" check your network settings, in particular Gateway and DNS.</div>
+<div id="t1" class="tip">A tick means I can reach the Internet. You need the Internet for VOIP calls.
+ If you have a problem reaching the Internet check your Network settings, in
+ particular Gateway and DNS.</div>
+<div id="t2" class="tip">Emergency backdoor IP. Useful if you get locked out of the main network connection, for
+ example due to DHCP problems on your network or a configuration mistake.
+ Write this number down somewhere!</div>
<table align="center" width=800>
EOF
<form action="/cgi-bin/set_network.sh" onsubmit="return validate_form(this)" method="get">
<table align="center" width=600>
<tr>
- <tr><td colspan="2" align="left"><h2>Network</h2></td>
+ <tr><td colspan="2" align="left" valign="top"><h2>Network</h2></td>
<tr>
<td><input type="radio" id="static" name="dhcp" value="no" onClick="doStatic()">Static</td>
<td><input type="radio" id="dhcp" name="dhcp" value="yes" onClick="doDHCP()">DHCP</td>
<tr><td>Netmask:</td><td><input type="text" name="netmask" id="netmask" onBlur="isIP(this)"></td></tr>
<tr><td>Gateway:</td><td><input type="text" name="gateway" id="gateway" onBlur="isIP(this)"></td></tr>
<tr><td>DNS:</td><td><input type="text" name="dns" id="dns" onBlur="isIP(this)"></td></tr>
+ <tr onMouseOver="popUp(event,'t2')" onmouseout="popUp(event,'t2')">
+ <td>Emergency IP:</td><td><input type="text" name="backdoor" id="backdoor" onBlur="isIP(this)"></td>
+ </tr>
<tr onMouseOver="popUp(event,'t1')" onmouseout="popUp(event,'t1')">
<td>Internet Connection:</td>
<td><div id="internet" >
netmask=`echo "$QUERY_STRING" | grep -oe "netmask=[^&?]*" | sed -n "s/netmask=//p"`
gateway=`echo "$QUERY_STRING" | grep -oe "gateway=[^&?]*" | sed -n "s/gateway=//p"`
dns=`echo "$QUERY_STRING" | grep -oe "dns=[^&?]*" | sed -n "s/dns=//p"`
+backdoor=`echo "$QUERY_STRING" | grep -oe "backdoor=[^&?]*" | sed -n "s/backdoor=//p"`
-echo `date` " set_network.sh $dhcp $ipaddress $netmask $gateway $dns" >> /tmp/easy_gui.log
+echo `date` " set_network.sh $dhcp $ipaddress $netmask $gateway $dns $backdoor" >> /tmp/easy_gui.log
if [ $dhcp == "yes" ]; then
/etc/init.d/network-static stop
/etc/init.d/network-static start
fi
+
+if [ -f /etc/rc.d/S05network-backdoor ]; then
+ sed -i "s/IPADDRESS=.*/IPADDRESS=\"$backdoor\"/g" /etc/init.d/network-backdoor
+ /etc/init.d/network-backdoor stop
+ /etc/init.d/network-backdoor start
+fi