2
0

g729_activate 903 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/perl
  2. use IPC::Run qw( run );
  3. use ESL;
  4. if(!$ARGV[0]) {
  5. print "$0 [licensecode]\n";
  6. exit 0;
  7. }
  8. my $code = $ARGV[0];
  9. chdir("/data/tmp");
  10. my $UNZIP;
  11. $UNZIP = "/usr/bin/unzip" if !(-x $UNZIP);
  12. $UNZIP = "/usr/local/bin/unzip" if !(-x $UNZIP);
  13. my $in = "$code\n\nY\n";
  14. my $err;
  15. my $out;
  16. my $activator = run ( ['/usr/bin/validator'],
  17. '<pty<', \$in, '>pty>', \$output );
  18. if($output =~ m/Success/) {
  19. if(-f "licences.zip") {
  20. run( [ $UNZIP, '-o', "-d", "/etc/freeswitch", 'licences.zip'], \$in, \$out, \$err );
  21. run( [ '/usr/bin/pkill', '-HUP', 'freeswitch_licence_server'], \$in, \$out, \$err );
  22. my $c = new ESL::ESLconnection("localhost", "8021", "ClueCon");
  23. my $e = $c->sendRecv('api g729_count');
  24. my $count = $e->getBody();
  25. print "Success, License count: $count\n";
  26. exit 0;
  27. }
  28. } else {
  29. print "Failed to activate.";
  30. exit 1;
  31. }