From dfb4cffb94c6f8e34c7c78f625bcf5242b5b54a9 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 15 Jan 2010 21:36:25 +0000 Subject: [PATCH] restart works git-svn-id: https://svn.code.sf.net/p/freetel/code@116 01035d8c-6547-0410-b346-abe4f91aad63 --- easy-asterisk-gui/Makefile | 2 +- easy-asterisk-gui/admin.sh | 44 +++++++++++++++++++++++++++------ easy-asterisk-gui/login.sh | 10 +++----- easy-asterisk-gui/phones.pl | 32 ++++++++++++++++++------ easy-asterisk-gui/restart.sh | 14 +++++++++++ easy-asterisk-gui/tooltips.html | 5 ++++ easy-asterisk-gui/voiplines.pl | 4 +-- 7 files changed, 88 insertions(+), 23 deletions(-) create mode 100644 easy-asterisk-gui/restart.sh diff --git a/easy-asterisk-gui/Makefile b/easy-asterisk-gui/Makefile index bc6998af..9f77282e 100644 --- a/easy-asterisk-gui/Makefile +++ b/easy-asterisk-gui/Makefile @@ -8,5 +8,5 @@ # make TESTIP=boris test test: - rcp voiplines.js set_voiplines.pl set_voiplines.sh voiplines.sh voiplines.pl set_ring.sh prototype.js admin.sh index.html faq.sh faq.html about.sh 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 + rcp restart.sh voiplines.js set_voiplines.pl set_voiplines.sh voiplines.sh voiplines.pl set_ring.sh prototype.js admin.sh index.html faq.sh faq.html about.sh 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 rcp sip.conf extensions.conf root@$(TESTIP):/etc/asterisk diff --git a/easy-asterisk-gui/admin.sh b/easy-asterisk-gui/admin.sh index b15373e0..f5c2fddd 100644 --- a/easy-asterisk-gui/admin.sh +++ b/easy-asterisk-gui/admin.sh @@ -15,6 +15,36 @@ if [ $? -eq 1 ]; then exit fi +# set password CGI + +echo "$QUERY_STRING" | grep -oe "pass=" > /dev/null +if [ $? -eq 0 ]; then + pass=`echo "$QUERY_STRING" | grep -oe "pass=[^&?]*" | sed -n "s/pass=//p"` + passwd_cmdline $pass +fi + +# restart CGI + +echo "$QUERY_STRING" | grep -oe "restart=1" > /dev/null +if [ $? -eq 0 ]; then + +# kill cookie to log out. This ensures hitting refresh wont run +# the restart process again + +cat < +Easy Asterisk - Restart + + +

Restarting...come back in 1 minute

+ +EOF +reboot +fi + # Construct the web page ------------------------------- cat < 

Change Phone System Password

- User: - Current Password: - New Password: + New Password:   - Default user/password is root/uClinux + Default password is uClinux   -

Restart Phone System

-
- +

Restart Phone System

+ + + +
  diff --git a/easy-asterisk-gui/login.sh b/easy-asterisk-gui/login.sh index db792eea..f195f8da 100644 --- a/easy-asterisk-gui/login.sh +++ b/easy-asterisk-gui/login.sh @@ -3,10 +3,9 @@ # David Rowe 4 Jan 2010 # CGI for Easy Asterisk login GUI -user=`echo "$QUERY_STRING" | grep -oe "user=[^&?]*" | sed -n "s/user=//p"` pass=`echo "$QUERY_STRING" | grep -oe "pass=[^&?]*" | sed -n "s/pass=//p"` -echo $QUERY_STRING | grep user > /dev/null +echo $QUERY_STRING | grep pass > /dev/null if [ $? -eq 1 ]; then # Display form ------------------------------- @@ -23,17 +22,16 @@ EOF - - +

Login

User:
Password:
Default user/password is root/uClinux
Default password is uClinux
EOF else - testuser $user $pass + testuser root $pass if [ $? -eq 0 ]; then # login sucessful @@ -43,10 +41,10 @@ else echo "" echo "Easy Asterisk - Login" echo '' + echo "" echo "" echo "Please wait a few seconds....." echo "" - echo "" else # login failed cat <) { close EXT; +# work out which IP phones are registered ----------------------------------- + my %sip = (); # SIP IP phone status keyed on sip.conf names (6011,6012 etc) # 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"; @@ -97,9 +97,10 @@ while () { #print "'$1'\n"; } } - if (/^(voip[0-9]*)[\s\/].*(OK)/) { - $voip{$1} = $2; - #print "'$1' '$2' $voip{$1}\n"; + + if (/^(.*)\/.*(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; @@ -110,7 +111,24 @@ while () { close SIP; -# start phones ringing form +# Determine if Asterisk can see current voip line (SIP trunk) +# sipshowpeers.txt needs to be generated before calling this perl +# script + +my %voip = (); # SIP trunks status keyed on sip.conf stanza name/username + # if no entry we can't see SIP trunk + +open SIP, "sipshowregistry.txt"; +while () { + if (/^(.*):.*(Registered)/) { + $voip{$1} = $2; + #print "'$1' '$2' $voip{$1}\n"; + } +} + +close SIP; + +# start phones ringing form ------------------------------------------- print '
'; @@ -187,7 +205,7 @@ $tooltip_voipline_ip = "onMouseOver=\"popUp(event,'phone_voipline_ip')\" onmouse $tooltip_voipline_prefix = "onMouseOver=\"popUp(event,'phone_voipline_prefix')\" onmouseout=\"popUp(event,'phone_voipline_prefix')\""; foreach $s (sort keys %voip) { - if ($voip{$s} eq "OK") { + if ($voip{$s} eq "Registered") { $icon = "\"VOIP"; print "1VOIP Line$ipad{$s}$icon\n"; } diff --git a/easy-asterisk-gui/restart.sh b/easy-asterisk-gui/restart.sh new file mode 100644 index 00000000..027dcf20 --- /dev/null +++ b/easy-asterisk-gui/restart.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# restart.sh +# David Rowe 15 Jan 2010 +# Restart script for Easy Asterisk GUI + +cat < +Easy Asterisk - Restart +Restarting...come back in 1 minute + +EOF +reboot + diff --git a/easy-asterisk-gui/tooltips.html b/easy-asterisk-gui/tooltips.html index b28082e8..dab4bffb 100644 --- a/easy-asterisk-gui/tooltips.html +++ b/easy-asterisk-gui/tooltips.html @@ -130,3 +130,8 @@ Internet Telephony Service Provider. Refresh your browser to update. +
+ Press this button to restart your phone + system. This is the same as turning the power + off and back on.
+ diff --git a/easy-asterisk-gui/voiplines.pl b/easy-asterisk-gui/voiplines.pl index 78c6f81e..64b5a2cc 100755 --- a/easy-asterisk-gui/voiplines.pl +++ b/easy-asterisk-gui/voiplines.pl @@ -76,7 +76,7 @@ open SIP, "sipshowregistry.txt"; while () { if (/^(.*):.*(Registered)/) { $voip{$1} = $2; - print "'$1' '$2' $voip{$1}\n"; + #print "'$1' '$2' $voip{$1}\n"; } } @@ -121,7 +121,7 @@ print "User:Password:\n"; print "Host:\n"; -print "\nXXX $provider_current $stanza{$provider_current} $voip{$stanza{$provider_current}}\n"; +#print "\nXXX $provider_current $stanza{$provider_current} $voip{$stanza{$provider_current}}\n"; if ($voip{$stanza{$provider_current}} eq "Registered") { $icon = "\"OK\""; -- 2.25.1