From 65a58f349abbc1ab368de38c37c12b28b74addd2 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Mon, 4 Jan 2010 09:35:22 +0000 Subject: [PATCH] tick and cross icons, sped up network indication by checking dns first git-svn-id: https://svn.code.sf.net/p/freetel/code@93 01035d8c-6547-0410-b346-abe4f91aad63 --- easy-asterisk-gui/Makefile | 2 +- easy-asterisk-gui/check_network.sh | 0 easy-asterisk-gui/cross.png | Bin 0 -> 959 bytes easy-asterisk-gui/dashboard.js | 5 ++++- easy-asterisk-gui/dashboard.sh | 9 ++++---- easy-asterisk-gui/menu.html | 10 ++++++++- easy-asterisk-gui/network.js | 7 +++++- easy-asterisk-gui/network.sh | 33 +++++++++++++++++++++-------- easy-asterisk-gui/set_network.sh | 9 +++++++- easy-asterisk-gui/tick.png | Bin 0 -> 1045 bytes 10 files changed, 56 insertions(+), 19 deletions(-) create mode 100644 easy-asterisk-gui/check_network.sh create mode 100644 easy-asterisk-gui/cross.png create mode 100644 easy-asterisk-gui/tick.png diff --git a/easy-asterisk-gui/Makefile b/easy-asterisk-gui/Makefile index d74d6568..e34e6d0a 100644 --- a/easy-asterisk-gui/Makefile +++ b/easy-asterisk-gui/Makefile @@ -9,4 +9,4 @@ TESTIP=192.168.1.150 # 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 diff --git a/easy-asterisk-gui/check_network.sh b/easy-asterisk-gui/check_network.sh new file mode 100644 index 00000000..e69de29b diff --git a/easy-asterisk-gui/cross.png b/easy-asterisk-gui/cross.png new file mode 100644 index 0000000000000000000000000000000000000000..05baecdbf71f9aae80e6d98952b09453ca17459f GIT binary patch literal 959 zcmV;w13>(VP)}DZ)(;L`xc8p- zy?f4g6n(V<3Yd31@AJ`expZJ;gq+q$vx#hPBT+;v2zU_$Y{qf4EAkoeMHSL6hw3A9 zf!qG!!yk^%%wSm-v|9VfOcWtuh%_1`VaR&3$v-0B0~e|g0a$&VeLXfk{ZaYM8LUD9 z<+@;5pgP|a0b_blX-cu(#xiEI0Vn6+o7*6|)8NJ7$;sI_PM=2Q^QdAGRVty69z_id zpz?X}Je22Q&CK9lx|E&EBW@mlZ_ff?n`rtv-`SVaJVeZ}~ zSzbos7-wMtJvD_{TVtnI!)$FKVTegnRv~J`n>O%)KR)i;whc*=;m8pvl>pGS8v4;A z^s!^;sVOjq-RsvuYm{vxmW57JhGC!%b2e~p(DyR|;ustUbMGG3!~_ftfl}D>^I+Qm zB+JW~hYz#&)j9)E0_t#11C_k%B0D>onqi1+Zj#)(g*<N$2!jSgjBGU7S>WP-i z6s~Bk^`MI5o;4&4F+qSleM)lkCN!HppDNo%6^ohDA{qM1famLQj-b>jx{!U6yb002ovPDHLkV1n%^yFCB^ literal 0 HcmV?d00001 diff --git a/easy-asterisk-gui/dashboard.js b/easy-asterisk-gui/dashboard.js index de163c23..74d6eaf1 100644 --- a/easy-asterisk-gui/dashboard.js +++ b/easy-asterisk-gui/dashboard.js @@ -1,4 +1,7 @@ function localInit() { - $('internet').innerHTML = init_internet; + if (init_internet == "yes") + $('internet').innerHTML = 'tick'; + else + $('internet').innerHTML = 'tick'; } diff --git a/easy-asterisk-gui/dashboard.sh b/easy-asterisk-gui/dashboard.sh index d1ea6944..db8d3b69 100644 --- a/easy-asterisk-gui/dashboard.sh +++ b/easy-asterisk-gui/dashboard.sh @@ -3,13 +3,12 @@ # 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 ------------------------------- @@ -46,7 +45,7 @@ cat < - +

Dashboard

Dashboard

Internet Connection:
diff --git a/easy-asterisk-gui/menu.html b/easy-asterisk-gui/menu.html index c8340175..4f3a5e47 100644 --- a/easy-asterisk-gui/menu.html +++ b/easy-asterisk-gui/menu.html @@ -1,14 +1,22 @@ +
Change your password
Monitor the status of your phone system
-
Set up the network and connect to the Internet
+
Connect the phone system to your network and the Internet
+
Set up your phones and phone calls
+ + + + + + diff --git a/easy-asterisk-gui/network.js b/easy-asterisk-gui/network.js index c49dc88d..108bf01b 100644 --- a/easy-asterisk-gui/network.js +++ b/easy-asterisk-gui/network.js @@ -57,7 +57,12 @@ function localInit() { $('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 = 'tick'; + else + $('internet').innerHTML = 'tick'; + } function validate_form(form) diff --git a/easy-asterisk-gui/network.sh b/easy-asterisk-gui/network.sh index bb93c28c..d4c0ee86 100644 --- a/easy-asterisk-gui/network.sh +++ b/easy-asterisk-gui/network.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -x # network.sh # David Rowe 4 Jan 2010 # CGI for Easy Asterisk network GUI @@ -22,13 +22,19 @@ then 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 ------------------------------- @@ -48,6 +54,7 @@ echo 'var init_ipaddress="'$ipaddress'";' 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 "" @@ -56,7 +63,12 @@ cat << EOF Easy Asterisk - Network -
Tells you if I can reach the Internet. If not "Good" check your network settings, in particular Gateway and DNS.
+
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.
+
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!

 

Admin
Dashboard
Network
Phones
Logout
EOF @@ -70,7 +82,7 @@ cat <
- + @@ -79,6 +91,9 @@ cat < + + +

Network

Network

Static DHCPNetmask:
Gateway:
DNS:
Emergency IP:
Internet Connection:
diff --git a/easy-asterisk-gui/set_network.sh b/easy-asterisk-gui/set_network.sh index 7ad68c6e..dddb65af 100755 --- a/easy-asterisk-gui/set_network.sh +++ b/easy-asterisk-gui/set_network.sh @@ -20,8 +20,9 @@ ipaddress=`echo "$QUERY_STRING" | grep -oe "ipaddress=[^&?]*" | sed -n "s/ipaddr 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 @@ -57,3 +58,9 @@ if [ $dhcp == "no" ]; 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 diff --git a/easy-asterisk-gui/tick.png b/easy-asterisk-gui/tick.png new file mode 100644 index 0000000000000000000000000000000000000000..c155dff45aab836b2182044d9ea3dbfe82c13e5c GIT binary patch literal 1045 zcmV+w1nT>VP)=yb?=?``#tY@THHHhj`KXLvpBzVp6B`h zAI0*R8B@S>z}|APG+wJ#i^@}EVu+K3BuH*qW4{MJrQSHb{JL5O8&ar48~W~leB;0{ zm1>!YgivAv8{tdDf(>akTZHpLE}=aL?4#a@?gq|`Z7qAnA0{?#>l?hMA0s(2DUrkk zavQcFAqx`FwgJ)A5a!J<2v1XQG;afE#x|6^;_oj$@>E}cbuAiAh9Q=OKw^9eS+F5( z2|6$d@omUjwVJ=KT|_Qt$AInB8%B3~_VvWbw!Z%AeNlpmA_;lxDLU z=3Vb)N)(xs>+Fv9^P4$~gTgvMpYG*qzEc-m?}?tC8ZjA>BouJ*B_fcB6obXmOO3a@ zos=ljl7Kz&N1V5R<0yqjcZS-l0k*r9O1UQ{rB~n;cL$H^QEo|_BX))hGDjjQlg`J7Q0F*Vrs8)_9l$bZX7kEsMqJVqVDt0-~Fv0`4IBeCM0I*n&niE(o zvXtG>fM&Iu~^2!w7r1SE$f!Fxgkvqoj&Jc5o`x2fF;y% zoTR=DIg-urYWyJ$dydWwR!dLu)4ExPEZ3t7kX?XLL`rr&a1ngATnPw_$g6@f&A5|b_d-na0NnFZcozHMHj ztfmp92mnM=CI% z!_E9SFiE{}dF2J$f%XD#