From: drowe67 Date: Tue, 12 Jan 2010 00:14:47 +0000 (+0000) Subject: working on voip lines screen X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=e0e683d2e6ef6e8d6577e646c26d7f8b508e1568;p=freetel-svn-tracking.git working on voip lines screen git-svn-id: https://svn.code.sf.net/p/freetel/code@107 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/easy-asterisk-gui/Makefile b/easy-asterisk-gui/Makefile index ed9f60d0..386bfe52 100644 --- a/easy-asterisk-gui/Makefile +++ b/easy-asterisk-gui/Makefile @@ -8,5 +8,5 @@ # make TESTIP=boris test test: - rcp 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 set_voiplines.pl 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/set_ring.sh b/easy-asterisk-gui/set_ring.sh index 17d928d8..c7b559c4 100644 --- a/easy-asterisk-gui/set_ring.sh +++ b/easy-asterisk-gui/set_ring.sh @@ -12,7 +12,7 @@ if [ $? -eq 1 ]; then echo '' echo "" echo "" -# exit + exit fi # extract extensions to ring and reload extensions.conf diff --git a/easy-asterisk-gui/set_voipline.sh b/easy-asterisk-gui/set_voipline.sh new file mode 100644 index 00000000..21b78446 --- /dev/null +++ b/easy-asterisk-gui/set_voipline.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# set_voipline.sh +# # David Rowe 12 Jan 2010 +# +# CGI to set voip line parameters in sip.conf. + +cat < + +set_network.sh + + +Please wait a few seconds..... + + + +EOF + +user=`echo "$QUERY_STRING" | grep -oe "user=[^&?]*" | sed -n "s/user=//p"` +pass=`echo "$QUERY_STRING" | grep -oe "pass=[^&?]*" | sed -n "s/pass=//p"` +host=`echo "$QUERY_STRING" | grep -oe "host=[^&?]*" | sed -n "s/host=//p"` + +./set_voipline.pl $user $pass $host > /etc/asterisk/sip.conf + +cat < + +set_voiplines.sh + + +Please wait a few seconds..... + + + +EOF \ No newline at end of file diff --git a/easy-asterisk-gui/set_voiplines.pl b/easy-asterisk-gui/set_voiplines.pl new file mode 100755 index 00000000..44e9f150 --- /dev/null +++ b/easy-asterisk-gui/set_voiplines.pl @@ -0,0 +1,61 @@ +#!/sbin/microperl +# set_voiplines.pl +# David Rowe 12 Jan 2010 +# +# Replaces fields in sip.conf, outputs new sip.conf contents to stdout + +$user = $ARGV[0]; +$pass = $ARGV[1]; +$host = $ARGV[2]; + +# slurp up voip trunk details -------------------------------- + +open SIP, "/etc/asterisk/sip.conf"; +$state = "looking for [voip]"; + +while () { + $next_state = $state; + + if ($state eq "looking for [voip]") { + + if (/^\[voip\]/) { + $next_state="inside [voip]"; + #print "$state $next_state\n"; + } + + print $_; + } + + if ($state eq "inside [voip]") { + + if (/^\[/) { + $next_state = "finished"; + } + + if (/user=/) { + print "user=$user\n"; + } + elsif (/secret=/) { + print "secret=$pass\n"; + } + elsif (/host=/) { + print "host=$host\n"; + } + else { + print $_; + } + } + + if ($state eq "finished") { + print $_; + } + + $state = $next_state; +} +close SIP; + +# generate form fields ------------------------------------------- + +print "User:\n"; +print "Password:"; +print "Host:"; diff --git a/easy-asterisk-gui/voipline.sh b/easy-asterisk-gui/voipline.sh deleted file mode 100644 index 2b2df315..00000000 --- a/easy-asterisk-gui/voipline.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# voipline.sh -# David Rowe 12 Jan 2010 -# VOIP Line screen for Easy Asterisk GUI - -# check we are logged in - -echo $HTTP_COOKIE | grep "loggedin" > /dev/null -if [ $? -eq 1 ]; then - echo "" - echo "" - echo '' - echo "" - echo "" - exit -fi - -# Construct the web page ------------------------------- - -cat < - - - -EOF - -cat << EOF - -Easy Asterisk - VOIP Line -EOF - -cat tooltips.html -echo '' -cat banner.html -echo " " -cat menu.html -cat < - -
- - - - - -EOF -./voipline.pl - -cat < - - - - -
 

VOIP Line

 
 
- - - - - - - - - -EOF - diff --git a/easy-asterisk-gui/voiplines.pl b/easy-asterisk-gui/voiplines.pl index bed92342..bbb1ca66 100755 --- a/easy-asterisk-gui/voiplines.pl +++ b/easy-asterisk-gui/voiplines.pl @@ -10,17 +10,22 @@ open SIP, "/etc/asterisk/sip.conf"; $state = "looking for [voip]"; while () { + $next_state = $state; + if ($state eq "looking for [voip]") { if (/^\[voip\]/) { - $state="inside [voip]"; + $next_state="inside [voip]"; + #print "$state $next_state\n"; } } - if (($state eq "inside [voip]") { + if ($state eq "inside [voip]") { + #print $_; if (/^\[/) { - $state = "finished"; + $next_state = "finished"; + #print "$next_state\n"; } if (/user=(.*)/) { @@ -33,11 +38,13 @@ while () { $host = $1; } } + + $state = $next_state; } close SIP; -# generate form --------------------------------------------- +# generate form fields ------------------------------------------- print "User:\n"; -print "Password:"; -print "Host:"; +print "Password:"; +print "Host:"; diff --git a/easy-asterisk-gui/voiplines.sh b/easy-asterisk-gui/voiplines.sh new file mode 100644 index 00000000..0bf0bcb8 --- /dev/null +++ b/easy-asterisk-gui/voiplines.sh @@ -0,0 +1,68 @@ +#!/bin/sh +# voiplines.sh +# David Rowe 12 Jan 2010 +# VOIP Line screen for Easy Asterisk GUI + +# check we are logged in + +echo $HTTP_COOKIE | grep "loggedin" > /dev/null +if [ $? -eq 1 ]; then + echo "" + echo "" + echo '' + echo "" + echo "" + exit +fi + +# Construct the web page ------------------------------- + +cat < + + + +EOF + +cat << EOF + +Easy Asterisk - VOIP Line +EOF + +cat tooltips.html +echo '' +cat banner.html +echo " " +cat menu.html +cat < + +
+ + + + + +EOF + +./voiplines.pl + +cat < + + + + +
 

VOIP Line

 
 
+ + + + + + + + + +EOF +