From 08892526f4b40eb3760f95a31ec4c0191a613a0e Mon Sep 17 00:00:00 2001 From: Brian West Date: Sat, 15 Mar 2014 20:49:08 -0500 Subject: [PATCH] remove cruf --- scripts/perl/FreeSWITCH-GizmoConfig.pl | 252 ------------------ .../perl/scenario/attended_transfer.button | 14 - scripts/perl/scenario/blind_transfer.button | 11 - scripts/perl/scenario/offhook.button | 8 - scripts/perl/scenario/phones.cfg | 4 - scripts/perl/scenario/runscenario.pl | 59 ---- 6 files changed, 348 deletions(-) delete mode 100644 scripts/perl/FreeSWITCH-GizmoConfig.pl delete mode 100644 scripts/perl/scenario/attended_transfer.button delete mode 100644 scripts/perl/scenario/blind_transfer.button delete mode 100644 scripts/perl/scenario/offhook.button delete mode 100644 scripts/perl/scenario/phones.cfg delete mode 100755 scripts/perl/scenario/runscenario.pl diff --git a/scripts/perl/FreeSWITCH-GizmoConfig.pl b/scripts/perl/FreeSWITCH-GizmoConfig.pl deleted file mode 100644 index cfe1fee52d..0000000000 --- a/scripts/perl/FreeSWITCH-GizmoConfig.pl +++ /dev/null @@ -1,252 +0,0 @@ -#!/usr/bin/perl - -# Simple script to add XML configuration for FreeSWITCH to use Gizmo5's phone network. -# This software has no support, warranty or liability: use at your own risk. -# Run without arguments for help. - -use strict; - -sub main () { - - my ($command) = parseArgs(); - my ($err) = checkArgs($command); - - if ($err) { - - usage($err); - exit(1); - - } - - - if ($command->{action} && $command->{action} =~ /^add/i) { - - if ($command->{object} && $command->{object} =~ /^gateway/i) { - - ($err) = createGizmo5Gateway($command) unless ($err); - ($err) = createGizmo5DialPlan($command) unless ($err); - - print "All files are in place. You must restart FreeSWITCH or run the console command: xml_reload\n" unless ($err); - print "for any changes to take effect.\n" unless ($err); - - } elsif ($command->{object} && $command->{object} =~ /^callin/i) { - - ($err) = createGizmo5Callin($command) unless ($err); - - print "All files are in place. You must restart FreeSWITCH or run the console command: xml_reload\n" unless ($err); - print "for any changes to take effect.\n" unless ($err); - - } - - - ### No support to remove yet. - } elsif ($command->{action} && $command->{action} =~ /^del/i) { - - if ($command->{object} && $command->{object} =~ /^gateway/i) { - - } elsif ($command->{object} && $command->{object} =~ /^callin/i) { - - } - - } - - if ($err) { - - print "Error: $err\n"; - exit(1); - - } - - exit(0); - -} - -sub createGizmo5Callin($) { - - my ($command) = @_; - - my $template = <<"END_O_FILE"; - - - - - - - - -END_O_FILE - - $template =~ s/SIP_LOCALUSER/$command->{extension}/g; - $template =~ s/SIP_DID/$command->{did}/g; - - return("Gizmo callin for $command->{did} appears to already exist at $command->{prefix}/conf/dialplan/public/01_gizmo-$command->{did}.xml") if (-e "$command->{prefix}/conf/dialplan/public/01_gizmo-$command->{did}.xml"); - - open(DEFAULT,">$command->{prefix}/conf/dialplan/public/01_gizmo-$command->{did}.xml") || return ("Unable to open $command->{prefix}/conf/dialplan/public/01_gizmo-$command->{did}.xml"); - print DEFAULT $template; - close (DEFAULT); - - return(); - -} - -sub createGizmo5DialPlan($) { - - my ($command) = @_; - my $template = <<"END_O_FILE"; - - - - - - - - - - - - - -END_O_FILE - - return ("Gizmo Default callout appears to already exist at $command->{prefix}/conf/dialplan/default/01_gizmo-$command->{username}.xml") if (-e "$command->{prefix}/conf/dialplan/default/01_gizmo-$command->{username}.xml"); - - open(DEFAULT,">$command->{prefix}/conf/dialplan/default/01_gizmo-$command->{username}.xml") || return("Unable to open $command->{prefix}/conf/dialplan/default/01_gizmo-$command->{username}.xml"); - print DEFAULT $template; - close (DEFAULT); - - - $template = <<"END_O_FILE"; - - - - - - - - - - - - - -END_O_FILE - - $template =~ s/SIP_DID/$command->{username}/g; - $template =~ s/SIP_LOCALUSER/$command->{extension}/g; - - return("Gizmo Default callin appears to already exist at $command->{prefix}/conf/dialplan/public/01_gizmo-$command->{username}.xml") if (-e "$command->{prefix}/conf/dialplan/public/01_gizmo-$command->{username}.xml"); - - open(DEFAULT,">>$command->{prefix}/conf/dialplan/public/01_gizmo-$command->{username}.xml") || return("Unable to open $command->{prefix}/conf/dialplan/public/01_gizmo-$command->{username}.xml"); - print DEFAULT $template; - close (DEFAULT); - - return(); -} - -sub createGizmo5Gateway($) { - - my ($command) = @_; - - my $template = <<"END_O_FILE"; - - - - - - - - - - - - - - - - - - - - - -END_O_FILE - - $template =~ s/SIP_USER/$command->{username}/g; - $template =~ s/SIP_PASS/$command->{password}/; - - return "Gizmo Gateway appears to already exist at $command->{prefix}/conf/directory/default/01_gizmo-$command->{username}.xml" if (-e "$command->{prefix}/conf/directory/default/01_gizmo-$command->{username}.xml"); - - open(GIZMO,">$command->{prefix}/conf/directory/default/01_gizmo-$command->{username}.xml") || return ("Unable to open $command->{prefix}/conf/directory/default/01_gizmo-$command->{username}.xml to write"); - print GIZMO $template; - close(GIZMO); - - return(); - -} - -sub checkArgs($) { - - my ($command) = @_; - my ($err) = 0; - - return("Bad Action") if (!defined $command->{action} || $command->{action} !~ /^(add)/); - return("Bad Object") if (!defined $command->{object} || $command->{object} !~ /^(gateway|callin)$/i); - return("Bad Username") if ($command->{action} && $command->{action} =~ /^add/i && (!defined $command->{username} || $command->{username} !~ /^1747\d{7}$/)); - return("Bad Extension") if ($command->{action} && $command->{action} =~ /^add/i && (!defined $command->{extension} || $command->{extension} eq '' )); - return("No Password Given") if ($command->{action} && $command->{action} =~ /^add/i && $command->{object} && $command->{object} =~ /^gateway/i && (!defined $command->{password} || $command->{password} eq '')); - return("No Local Extension Given") if ($command->{action} && $command->{action} =~ /^add/i && $command->{object} && $command->{object} =~ /^callin/i && (!defined $command->{extension} || $command->{extension} eq '')); - return("DID must be purely numeric") if ($command->{action} && $command->{action} =~ /^add/i && $command->{object} && $command->{object} =~ /^callin/i && (!defined $command->{did} || $command->{did} !~ /^\d+$/)); - - - return("Cannot find FreeSWITCH install at $command->{prefix}") unless (-e "$command->{prefix}/conf" && -d "$command->{prefix}/conf"); - return("Cannot write to FreeSWITCH install at $command->{prefix}") unless (-w "$command->{prefix}/conf"); - - return(); - -} - -sub parseArgs() { - - my $command; - - foreach (@ARGV) { - - if (/^(.*)=(.*)/) { - - $command->{lc($1)} = $2; - - } - - } - - $command->{action} = $ARGV[0] || undef; - $command->{object} = $ARGV[1] || undef; - $command->{prefix} = '/usr/local/freeswitch' unless ($command->{prefix} && $command->{prefix} ne ''); - return ($command); - -} - - -sub usage($) { - - my ($err) = @_; - - print STDERR "$err\n" if ($err); - print STDERR "Usage: ./FreeSWITCH-GizmoConfig.pl action object [arguments [...]]\n"; - print STDERR "Valid actions:\n"; - print STDERR "add gateway username=1747NNNNNNN password=xxxxxx extension=YourExtension [prefix=/usr/local/freeswitch]\n"; - print STDERR "add callin did=NNNNNNNNN extension=YourExension [prefix=/usr/local/freeswitch]\n"; - print STDERR "\n"; - print STDERR "Example of adding user 17472075873:\n"; - print STDERR "./FreeSWITCH-Gizmo.pl add gateway username=17472075873 password=Secret extension=1001\n"; - print STDERR "\n"; - print STDERR "Adding support for a US callin Number: +1-858-625-0499 (You must add a user that purchased the number to receive calls):\n"; - print STDERR "./FreeSWITCH-Gizmo.pl add callin did=18586250499 extension=1001\n"; - print STDERR "\n"; - print STDERR "Adding support for a UK or other International callin Number: +44 20 7499-9000 :\n"; - print STDERR "./FreeSWITCH-Gizmo.pl add callin did=442074999000 extension=brian\n"; - -} - -main(); - diff --git a/scripts/perl/scenario/attended_transfer.button b/scripts/perl/scenario/attended_transfer.button deleted file mode 100644 index c46e79af2c..0000000000 --- a/scripts/perl/scenario/attended_transfer.button +++ /dev/null @@ -1,14 +0,0 @@ -Snom_300,key,CANCEL -Snom_360,key,CANCEL -Snom_370,key,CANCEL -Snom_300,key,ONHOOK -Snom_360,key,ONHOOK -Snom_370,key,ONHOOK,1 -Snom_300,number,1006,1 -Snom_360,key,OFFHOOK, 1 -Snom_360,key,F_HOLD, 1 -Snom_360,number,1007,2 -Snom_370,key,OFFHOOK,1 -Snom_360,key,F_TRANSFER,2 -Snom_360,key,ONHOOK - diff --git a/scripts/perl/scenario/blind_transfer.button b/scripts/perl/scenario/blind_transfer.button deleted file mode 100644 index 71f3ea8cd0..0000000000 --- a/scripts/perl/scenario/blind_transfer.button +++ /dev/null @@ -1,11 +0,0 @@ -Snom_300,key,CANCEL -Snom_360,key,CANCEL -Snom_370,key,CANCEL -Snom_300,key,ONHOOK -Snom_360,key,ONHOOK -Snom_370,key,ONHOOK,1 -Snom_300,number,1006,1 -Snom_360,key,OFFHOOK,1 -Snom_360,key,F_TRANSFER,1 -Snom_360,number,1007,2 -Snom_370,key,OFFHOOK,1 diff --git a/scripts/perl/scenario/offhook.button b/scripts/perl/scenario/offhook.button deleted file mode 100644 index 79d61d578b..0000000000 --- a/scripts/perl/scenario/offhook.button +++ /dev/null @@ -1,8 +0,0 @@ -Snom_300,key,OFFHOOK -Snom_320,key,OFFHOOK -Snom_360,key,OFFHOOK -Snom_370,key,OFFHOOK -Snom_300,key,ONHOOK -Snom_320,key,ONHOOK -Snom_360,key,ONHOOK -Snom_370,key,ONHOOK diff --git a/scripts/perl/scenario/phones.cfg b/scripts/perl/scenario/phones.cfg deleted file mode 100644 index a3dbf2855c..0000000000 --- a/scripts/perl/scenario/phones.cfg +++ /dev/null @@ -1,4 +0,0 @@ -Snom_300,10.0.1.17,1000 -Snom_320,10.0.1.242,1002 -Snom_360,10.0.1.243,1006 -Snom_370,10.0.1.244,1007 diff --git a/scripts/perl/scenario/runscenario.pl b/scripts/perl/scenario/runscenario.pl deleted file mode 100755 index 14b7515a3d..0000000000 --- a/scripts/perl/scenario/runscenario.pl +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/perl -# -# Scenario Test Execution. -# -use LWP::UserAgent; -use Data::Dumper; - -$| =1; - -our $ua = LWP::UserAgent->new; -my $phone = load_config(); - -if(-f $ARGV[0]) { - run_scenario($ARGV[0]); -} else { - print "No Scenario File?\n"; - exit; -} - -sub run_scenario($$) { - $file = shift; - open(SCENARIO,"<$file"); - @commands = ; - print Dumper $info; - foreach $command (@commands) { - chomp $command; - my($target, $type, $button, $delay) = split(",",$command); - &push_button($phone->{$target}, "$type", "$button", $delay); - - } -} - -sub push_button ($$$) { - $info = shift; - $type = shift; - $button = shift; - $delay = shift; - - if($delay) { - sleep($delay); - } else { - $delay = 0; - } - print "$info->{name} -> $type => $button with delay $delay\n"; - - $request = HTTP::Request->new("GET", "http://$info->{ip}/command.htm?$type=$button"); - $return = $ua->request($request); -} - -sub load_config { - open(CFG,"; - foreach $line (@phones) { - chomp $line; - my($name,$ip,$extension) = split(",", $line); - $phone->{$name} = {name => $name, ip => $ip, extension => $extension} - } - return $phone; -}