User Permissions

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.

Comments

  • 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,
  • Hi.

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

    Thanks about the reload info.
  • Can we please chat to you online???
  • 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
  • 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.
Sign In or Register to comment.