From: drowe67 Date: Thu, 14 Jan 2010 09:34:20 +0000 (+0000) Subject: saving voip lines OK X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=3132ba9ff9337ba045869a7485d95d3e7590a40e;p=freetel-svn-tracking.git saving voip lines OK git-svn-id: https://svn.code.sf.net/p/freetel/code@111 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/easy-asterisk-gui/set_voiplines.pl b/easy-asterisk-gui/set_voiplines.pl index 674be003..b38112bf 100755 --- a/easy-asterisk-gui/set_voiplines.pl +++ b/easy-asterisk-gui/set_voiplines.pl @@ -7,57 +7,64 @@ $user = $ARGV[0]; $pass = $ARGV[1]; $host = $ARGV[2]; -$provider = $ARGV[3]; +$provider_new = $ARGV[3]; -# slurp up voip trunk details -------------------------------- +# We need to slurp up the easy asterisk provider and spit them +# back out. All must be commented out except for the one that +# is selected. Hopefully non-easy asterisk content of sip.conf +# won't be affected. open SIP, "/etc/asterisk/sip.conf"; -$state = "looking for easy-asterisk"; - +$provider = ""; while () { - $next_state = $state; - if ($state eq "looking for easy-asterisk") { - - if (/[voip\]/) { - $next_state="inside [voip]"; - #print "$state $next_state\n"; - } + # start of any new stanza switches off parsing. It may get + # switched back on below if it contains easy-asterisk + # keyword. This allows non-easy asterisk SIP devices to be + # included in sip.conf - print $_; + if (/\[/) { + $provider = ""; } - if ($state eq "inside [voip]") { + # look for commented or uncommented easy asterisk provider stanza - if (/^\[/) { - $next_state = "finished"; - } - if (/^;.*\[/) { - $next_state = "finished"; - } + if (/\[.* \"(.*)\" easy-asterisk/) { + $provider = $1; + } - if (/^user=/) { - print "user=$user\n"; - } - elsif (/^fromuser=/) { - print "fromuser=$user\n"; - } - elsif (/^secret=/) { - print "secret=$pass\n"; - } - elsif (/^host=/) { - print "host=$host\n"; + if ($provider ne "") { + # OK, we are in an easy-asterisk stanza + + # strip off any leading ";" + + $_ =~ s/^\;//; + + if ($provider eq $provider_new) { + + # this stanza should be uncommented + + if (/^user=/) { + print "user=$user\n"; + } + elsif (/^fromuser=/) { + print "fromuser=$user\n"; + } + elsif (/^secret=/) { + print "secret=$pass\n"; + } + elsif (/^host=/) { + print "host=$host\n"; + } + else { + print $_; + } } else { - print $_; + print ";$_"; } } - if ($state eq "finished") { - print $_; - } - - $state = $next_state; } close SIP; diff --git a/easy-asterisk-gui/voiplines.pl b/easy-asterisk-gui/voiplines.pl index 3c2dfd51..e2478e7d 100755 --- a/easy-asterisk-gui/voiplines.pl +++ b/easy-asterisk-gui/voiplines.pl @@ -20,7 +20,7 @@ while () { # back on below if it contains easy-asterisk keyword. This allows # non-easy asterisk SIP devices to be included in sip.conf - if (/^\[/) { + if (/\[/) { $provider = ""; }