From b3c3c4c943ac155ca568f168ca5e7a7c6b73889d Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 12 Mar 2009 20:04:24 +0000 Subject: [PATCH] added flag option to install.pl to not show any prompts added signalonly option to send dtmf AGI to only send signal, not audio git-svn-id: svn://192.168.202.10@1072 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/agi/agi-dtmf.agi | 134 +++++++++++++++-------- agc_2-X/trunk/bin/start_asterisk_boot.pl | 3 + agc_2-X/trunk/install.pl | 40 ++++--- 3 files changed, 110 insertions(+), 67 deletions(-) diff --git a/agc_2-X/trunk/agi/agi-dtmf.agi b/agc_2-X/trunk/agi/agi-dtmf.agi index b2b95eea..4311aa9e 100644 --- a/agc_2-X/trunk/agi/agi-dtmf.agi +++ b/agc_2-X/trunk/agi/agi-dtmf.agi @@ -7,19 +7,43 @@ # Accepted values are: 1 2 3 4 5 6 7 8 9 0 # * , # comma means pause for 1 second # -# Copyright (C) 2006 Matt Florell LICENSE: AGPLv2 +# exten => 8500998,1,Answer +# exten => 8500998,2,Playback(silence) +# exten => 8500998,3,AGI(agi-dtmf.agi) +#; exten => 8500998,3,AGI(agi-dtmf.agi,signalonly) ; optional signal only DTMF +# exten => 8500998,4,Hangup +# +# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 +# +# CHANGES +# 90312-1534 - Added signalonly option # +$signalonly=0; +### begin parsing run-time options ### +if (length($ARGV[0])>1) + { + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($ARGV[0] =~ /signalonly/) + {$signalonly=1;} + } + $|=1; -while() { +while() + { chomp; last unless length($_); - if (/^agi_(\w+)\:\s+(.*)$/) { - $AGI{$1} = $2; - } + if (/^agi_(\w+)\:\s+(.*)$/) + {$AGI{$1} = $2;} if (/^agi_callerid\:\s+(.*)$/) {$caller_id = $1;} - if (/^agi_calleridname\:\s+(.*)$/) {$caller_idname = $1;} -} + if (/^agi_calleridname\:\s+(.*)$/) {$caller_idname = $1;} + } print STDERR "AGI Environment Dump:\n"; foreach $i (sort keys %AGI) { @@ -37,6 +61,63 @@ my $clidname = $agi->get_variable('CALLERIDNAME'); print STDERR "X. |$clid|$caller_id|$clidname|\n"; +### sleep for 5 tenths of a second +usleep(1*500*1000); + +print "STREAM FILE silence \"\"\n"; + +$caller_id = "$caller_id$caller_idname"; + +@CALLERID_DIGITS = split(//, $caller_id); + +foreach (@CALLERID_DIGITS) +{ + +if ($CALLERID_DIGITS[$g] =~ /\d/) + { + if ($signalonly > 0) + {print "EXEC SendDTMF $CALLERID_DIGITS[$g] \"\"\n";} + else + {print "STREAM FILE $CALLERID_DIGITS[$g] \"\"\n";} + print STDERR "DIGIT: $CALLERID_DIGITS[$g]\n"; + } +else + { + if ($CALLERID_DIGITS[$g] =~ /\#/) + { + if ($signalonly > 0) + {print "EXEC SendDTMF \# \"\"\n";} + else + {print "STREAM FILE hash \"\"\n";} + } + if ($CALLERID_DIGITS[$g] =~ /\*/) + { + if ($signalonly > 0) + {print "EXEC SendDTMF \* \"\"\n";} + else + {print "STREAM FILE star \"\"\n";} + } + if ($CALLERID_DIGITS[$g] =~ /\,/) + {sleep(1);} + print STDERR "NON-DIGIT: $CALLERID_DIGITS[$g]\n"; + } +$g++; + +### sleep for 20 hundredths of a second +usleep(1*150*1000); + +print "STREAM FILE silence \"\"\n"; + +### sleep for 10 hundredths of a second +usleep(1*100*1000); +} + +print "STREAM FILE silence \"\"\n"; +$result = ; +checkresult($result); + +exit; + sub checkresult { my ($res) = @_; my $retval; @@ -57,42 +138,3 @@ sub checkresult { } } -### sleep for 5 tenths of a second -usleep(1*500*1000); - -print "STREAM FILE silence \"\"\n"; - -$caller_id = "$caller_id$caller_idname"; - -@CALLERID_DIGITS = split(//, $caller_id); - -foreach (@CALLERID_DIGITS) -{ - -if ($CALLERID_DIGITS[$g] =~ /\d/) - { - print "STREAM FILE $CALLERID_DIGITS[$g] \"\"\n"; - print STDERR "DIGIT: $CALLERID_DIGITS[$g]\n"; - } -else - { - if ($CALLERID_DIGITS[$g] =~ /\#/) {print "STREAM FILE hash \"\"\n";} - if ($CALLERID_DIGITS[$g] =~ /\*/) {print "STREAM FILE star \"\"\n";} - if ($CALLERID_DIGITS[$g] =~ /\,/) {sleep(1);} - print STDERR "NON-DIGIT: $CALLERID_DIGITS[$g]\n"; - } -$g++; - -### sleep for 20 hundredths of a second -usleep(1*150*1000); - -print "STREAM FILE silence \"\"\n"; - -### sleep for 10 hundredths of a second -usleep(1*100*1000); -} - -print "STREAM FILE silence \"\"\n"; -$result = ; -checkresult($result); - diff --git a/agc_2-X/trunk/bin/start_asterisk_boot.pl b/agc_2-X/trunk/bin/start_asterisk_boot.pl index 13292594..349ff578 100644 --- a/agc_2-X/trunk/bin/start_asterisk_boot.pl +++ b/agc_2-X/trunk/bin/start_asterisk_boot.pl @@ -84,6 +84,9 @@ if (-e "/root/asterisk_command_reload_iax2") } `$findbin /root/ -maxdepth 1 -name "asterisk_command*" -print | xargs rm -f`; + + `ulimit -n 65536`; + } if ($SYSLOG) diff --git a/agc_2-X/trunk/install.pl b/agc_2-X/trunk/install.pl index c2c15ee2..8b65ad56 100644 --- a/agc_2-X/trunk/install.pl +++ b/agc_2-X/trunk/install.pl @@ -16,6 +16,7 @@ # 80316-2208 - Added $PATHlogs/archive for backups # 80526-1345 - Added Timeclock auto-logout option 9 # 90210-0319 - Added option to prompt for Asterisk version +# 90312-1256 - Added CLI flag for automatic configuration # ############################################ @@ -142,6 +143,7 @@ if (length($ARGV[0])>1) print " [--help] = this help screen\n"; print " [--test] = test (will not copy files)\n"; print " [--debug] = verbose debug messages\n"; + print " [--no-prompt] = do not ask questions, just install\n"; print " [--web-only] = only copy files/directories for web server install\n"; print " [--without-web] = do not copy web files/directories\n\n"; print "configuration options:\n"; @@ -196,27 +198,19 @@ if (length($ARGV[0])>1) exit; } else - { + { if ($args =~ /--debug/i) # Debug flag - { - $DB=1; - } + {$DB=1;} if ($args =~ /--test/i) # test flag - { - $TEST=1; $T=1; - } + {$TEST=1; $T=1;} if ($args =~ /--web-only/i) # web-only flag - { - $WEBONLY=1; - } + {$WEBONLY=1; } if ($args =~ /--without-web/i) # without web flag - { - $NOWEB=1; - } + {$NOWEB=1;} else - { - $NOWEB=0; - } + {$NOWEB=0;} + if ($args =~ /--no-prompt/i) # do not ask questions + {$NOPROMPT=1;} if ($args =~ /--home=/i) # CLI defined home path { @CLIhomeARY = split(/--home=/,$args); @@ -1001,10 +995,13 @@ if (-e "$PATHconf") } } -print("\nWould you like to use manual configuration and installation(y/n): [y] "); -$manual = ; -chomp($manual); -if ($manual =~ /n/i) +if (!$NOPROMPT) + { + print("\nWould you like to use manual configuration and installation(y/n): [y] "); + $manual = ; + chomp($manual); + } +if ( ($manual =~ /n/i) || ($NOPROMPT > 0) ) { $manual=0; } @@ -2237,9 +2234,10 @@ if ($NOWEB < 1) `chmod 0777 $PATHweb/vicidial/server_reports/`; } -if ($PROMPTcopy_conf_files =~ /y/i) +if ( ($PROMPTcopy_conf_files =~ /y/i) || ($CLIcopy_conf_files =~ /y/i) ) { print "Copying sample conf files to /etc/asterisk/...\n"; + `mkdir -p /etc/asterisk`; if ($VARasterisk_version =~ /^1.2/) { `cp -f ./docs/conf_examples/extensions.conf.sample /etc/asterisk/extensions.conf`;