Config Script for Thirdlane?

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

Comments

  • 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";
    }
    
    
  • what do we do after we create these files?
  • how do we set FOP2 to execute those scripts, it doesn't seem like #exec works with perl
  • 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
  • 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.
  • 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,
  • I'm using a single tenant thirdlane installation, will this change how the scripts work?
  • Most proably the script will require some tweaking. Run them and inspect the output to find out what you have.
Sign In or Register to comment.