From 4f7a29de5e6c42c3bb12953ebc80e82bd01da4ec Mon Sep 17 00:00:00 2001 From: Brian West Date: Tue, 23 Feb 2016 11:00:10 -0600 Subject: [PATCH] test script --- scripts/perl/g729_activate | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 scripts/perl/g729_activate diff --git a/scripts/perl/g729_activate b/scripts/perl/g729_activate new file mode 100644 index 0000000000..d900a2e425 --- /dev/null +++ b/scripts/perl/g729_activate @@ -0,0 +1,39 @@ +#!/usr/bin/perl + +use IPC::Run qw( run ); +use ESL; + +if(!$ARGV[0]) { + print "$0 [licensecode]\n"; + exit 0; +} + +my $code = $ARGV[0]; + +chdir("/data/tmp"); + +my $UNZIP; +$UNZIP = "/usr/bin/unzip" if !(-x $UNZIP); +$UNZIP = "/usr/local/bin/unzip" if !(-x $UNZIP); + +my $in = "$code\n\nY\n"; +my $err; +my $out; + +my $activator = run ( ['/usr/bin/validator'], + 'pty>', \$output ); + +if($output =~ m/Success/) { + if(-f "licences.zip") { + run( [ $UNZIP, '-o', "-d", "/etc/freeswitch", 'licences.zip'], \$in, \$out, \$err ); + run( [ '/usr/bin/pkill', '-HUP', 'freeswitch_licence_server'], \$in, \$out, \$err ); + my $c = new ESL::ESLconnection("localhost", "8021", "ClueCon"); + my $e = $c->sendRecv('api g729_count'); + my $count = $e->getBody(); + print "Success, License count: $count\n"; + exit 0; + } +} else { + print "Failed to activate."; + exit 1; +}