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. User Permissions

User Permissions

Scheduled Pinned Locked Moved Support
6 Posts 2 Posters 87 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.
  • 2
    2
    255
    wrote on last edited by
    #1

    Hi.

    I have made a bash script that gets the users permissions from another file, the bash script works fine and the fop2.cfg file can execute it. However, the output configurations from my bash file aren't being applied to the configuration.

    Below is my bash script which prints out the new user permissions in the correct syntax

    #!/bin/bash
    for USER in `cat /etc/asterisk/voicemail.conf | grep "=>" | cut -d, -f1 | sed 's/ => /:/g'`
    do
     echo "$USER" > tmpUserFile
     USEREXT=`cat ./tmpUserFile | cut -d, -f1 | sed 's/ => /:/g' | cut -d: -f1`
    
     for CHKUSER in `cat ./manual-user-rights.cfg | cut -d: -f1`;
     do
      if [ "$USEREXT" == "$CHKUSER" ]
      then
        USERRIGHTS=`cat ./manual-user-rights.cfg | grep "$USEREXT" | cut -d: -f2`;
        echo "user=$USER:$USERRIGHTS";
      fi
     done
    
     rm -r ./tmpUserFile
    done
    echo "buttonfile=autobuttons.cfg"
    

    Perhaps some line issue with the echo? not recognizing the line break?

    Also can anybody tell me when the fop2.cfg is executed. Eg. is the configuration re-run when users log in, or does the fop2.cfg only re-run when the service is restarted?

    Cheers.

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

      Hi,

      It seems your script is not writing the user secret ?

      echo "user=$USER:Where_is_the_sercret?:$USERRIGHTS";

      The script is executed every time you start or reload fop2_server . The reload is done by sending a HUP signal to the process.

      Best regards,

      1 Reply Last reply
      0
      • 2
        2
        255
        wrote on last edited by
        #3

        Hi.

        The user secret and extension are both held in the $USER variable.

        Thanks about the reload info.

        1 Reply Last reply
        0
        • 2
          2
          255
          wrote on last edited by
          #4

          Can we please chat to you online???

          1 Reply Last reply
          0
          • 2
            2
            255
            wrote on last edited by
            #5

            Still having the same problem as before, although I have cleaned up the code a bit.
            This is the revised code.

            #!/bin/bash
            
            for EXTNO in `cat /etc/asterisk/voicemail.conf | grep "=>" | cut -d, -f1 | sed 's/ => /:/g' | cut -d: -f1`
            do
            
             for CHKNO in `cat ./manual-user-rights.cfg | cut -d: -f1`
             do
            
              if [ "$EXTNO" == "$CHKNO" ]
              then
            
               PERMISSIONS=`cat ./manual-user-rights.cfg | grep "$EXTNO" | cut -d: -f2`
               SECRET=`cat /etc/asterisk/voicemail.conf | grep "$EXTNO =>" | cut -d, -f1 | sed 's/ => /:/g' | cut -d: -f2`
            
               echo "user=$EXTNO:$SECRET:$PERMISSIONS"
            
              fi
            
             done
            
            done
            
            echo "buttonfile=autobuttons.cfg"
            

            When I call the script directly it executes fine, with correct output. When I execute 'fop2_server restart'. It executes the script but the config from the script doesn't seem to be loading. When I execute 'service fop2 restart' the script doesn't even get executed.

            Output from the script when called directly:

            user=4006:4006:pickup
            user=4003:4003:all
            user=4256:4256:pickup,hangup,dial
            buttonfile=autobuttons.cfg
            

            The format of 'manual-user-rights.cfg' is:

            ext:permissions
            4003:all
            4006:pickup
            4256:pickup,hangup,dial
            

            It doesn't appear to be a file permission issue as I am using the default file. If I use the default script, It runs when 'service fop2 restart' and 'fop2_server restart' are executed whereas if I use my code, it only runs on 'fop2_server restart'

            Any help would be greatly appreciated

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

              Hi,

              The "start, stop, restart" are only available on the init script, not on fop2_server itself. If the init script works fine, your #exec script will be executed. Remember that you have to set the execute permissions to your script too...

              Best regards,

              PS: I am online now, and will be online for one more hour.

              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