Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

FOP2 Community Forum

  1. Home
  2. Support
  3. Config Script for Thirdlane?

Config Script for Thirdlane?

Scheduled Pinned Locked Moved Support
9 Posts 4 Posters 79 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    D
    dozment
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • N
      N
      nicolas
      wrote on last edited by
      #2

      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";
      }
      
      
      1 Reply Last reply
      0
      • C
        C
        cyford33
        wrote on last edited by
        #3

        what do we do after we create these files?

        1 Reply Last reply
        0
        • C
          C
          cyford33
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • N
            N
            nicolas
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • S
              S
              steedman
              wrote on last edited by
              #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.

              1 Reply Last reply
              0
              • N
                N
                nicolas
                wrote on last edited by
                #7

                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,

                1 Reply Last reply
                0
                • S
                  S
                  steedman
                  wrote on last edited by
                  #8

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

                  1 Reply Last reply
                  0
                  • N
                    N
                    nicolas
                    wrote on last edited by
                    #9

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

                    1 Reply Last reply
                    0

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    Powered by NodeBB Contributors
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups