Config Script for Thirdlane?

  1. 13 years ago

    I'm running FOP2 in a Thirdlane multi-tenant environment. We have been running it for some time now, and when I implemented it I had a config script for Thirdlane. But, I can't find that script. Is there any chance it is still floating around somewhere? Even if it isn't a complete script I would like to take a look to see if there is a way to automatically build configuration files from a Thirdlane environment.

    Thanks!
    Dan

  2. admin

    5 Apr 2011 Administrator

    autoconfig-users-thirdlane.pl

    #!/usr/bin/perl
    
    $file = "/etc/asterisk/voicemail.conf";
    
    open( CONFIG, "<$file" ) or die("Could not open $file");
    
    while (<CONFIG>) {
       chomp;
       $_ =~ s/^\s+//g;
       $_ =~ s/([^;]*)[;](.*)/$1/g;
       $_ =~ s/\s+$//g;
    
       if ( /^#/ || /^;/ || /^$/ ) {
           next;
       }    # Ignores comments and empty lines
    
       if (/^\Q[\E/) {
           s/\[(.*)\]/$1/g;
           $context = $_;
           if($context =~ /^default/) {
               $context =~ s/^default-//g;
               if($hubo>0) {
                   print "buttonfile=automatic-thirdlane-buttons.cfg $oldcontext\n\n";
                   $hubo=0;
               }
               if($context ne "default") {
                  print "[$context]\n";
               }
           }
       }
       if (/=>/) {
           $_ =~ s/\s//g;
           @partes = split(/=>/,$_,2);
           $exten = $partes[0];
           $resto = $partes[1];
           @partes = split(/,/,$resto,2);
           $secret = $partes[0];
           $oldcontext=$context;
           print "user=$exten:$secret:all\n";
           $hubo++;
       }
    
    }
    close(CONFIG);
    
    print "buttonfile=automatic-thirdlane-buttons.cfg $oldcontext\n\n";

    automatic-thirdlane-buttons.cfg

    #exec autoconfig-buttons-thirdlane.pl $1

    autoconfig-buttons-thirdlane.pl

    #!/usr/bin/perl
    
    $file = "/etc/asterisk/users.txt";
    
    $mycontext = $ARGV[0];
    
    open( CONFIG, "<$file" ) or die("Could not open $file");
    
    while (<CONFIG>) {
       chomp;
       $_ =~ s/^\s+//g;
       $_ =~ s/([^;]*)[;](.*)/$1/g;
       $_ =~ s/\s+$//g;
    
       if ( /^#/ || /^;/ || /^$/ ) {
           next;
       }    # Ignores comments and empty lines
    
       if (/^\Q[\E/) {
           s/\[(.*)\]/$1/g;
           $context = $_;
           @partes = split (/-/,$context,2);
           $context= $partes[0];
           $extension = $partes[1];
           if($context eq $mycontext) {
              $dale=1;
           } else {
              $dale=0;
           }
       } else {
           if($dale==1) {
             my ($key,$val) = split(/=/,$_,2);
             $config->{$mycontext}{$extension}{$key}=$val;
           }
       }
    }
    close(CONFIG);
    while ( my ( $uno, $dos ) = each( %{ $config->{$mycontext} } ) ) {
       $label = $dos->{first_name}." ".$dos->{last_name};
       $exten = $dos->{ext};
       $ctx = "from-inside-$mycontext";
       $mbox = $dos->{mailbox};
       $chan = $dos->{phones};
       print "[$chan]\n";
       print "type=extension\n";
       print "extension=$exten\n";
       print "context=$ctx\n";
       print "label=$label\n";
       print "mailbox=$mbox\n\n";
    }
    
  3. 12 years ago

    what do we do after we create these files?

  4. how do we set FOP2 to execute those scripts, it doesn't seem like #exec works with perl

  5. admin

    5 Jun 2012 Administrator

    You execute scripts via the #exec setting in fop2.cfg

    Look at the end of your fop2.cfg file, you probably have this:

    #exec autoconfig-users-freepbx.sh

    change that to

    #exec autoconfig-buttons-thirdlane.pl

    Also, do not forget to set execute permissions to all .pl scripts

    chmod a+x *.pl

  6. I don't mean to revive an old thread, but I cant seem to get this to work. Are there new scripts to use with thirdlane? and did you mean to #exec autoconfig-users-thirdlane.pl in fop2.cfg? or is autoconfig-buttons-thirdlane.pl correct? I have tried both.

  7. admin

    16 Oct 2012 Administrator

    You are right, the script to execute in fop2.cfg is autoconfig-users-thirdlane.pl

    You also need to create a file named automatic-thirdlane-buttons.cfg with the contents:

    #exec autoconfig-buttons-thirdlane.pl

    Now, those are not fully features, they are to be used as a base to adapt to your system/requirements. Read the scripts , run them in the console, inspect their output.

    They will create a basic multi tenant setup, with users for each tenant that is defined in a separate panel-context, so you have to login with ?context=tenant in the fop2 url.

    Best regards,

  8. I'm using a single tenant thirdlane installation, will this change how the scripts work?

  9. admin

    16 Oct 2012 Administrator

    Most proably the script will require some tweaking. Run them and inspect the output to find out what you have.

or Sign Up to reply!