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.
-
-
-
-
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.cfgThe format of 'manual-user-rights.cfg' is:
ext:permissions 4003:all 4006:pickup 4256:pickup,hangup,dialIt 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.
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