set shell user to call script in rails

0

I need to call a shell script from rails, with a specific shell user.

Example:

update_response = '#{deploy_dir}/./update.sh'

By default my system is using root.

I would like to know, given this example, if you have how to specify the user and if you have a way to generalize the script calls to the same user.

    
asked by anonymous 03.07.2018 / 15:35

2 answers

0

You can use sudo -u username

    
03.07.2018 / 19:45
0

Solution found using the shell itself to perform the script call with another user.

update_response = 'su -c '#{deploy_dir}/./update.sh' - #{user}'

We can from this solution create a generic function for script calls passing script path and one user per parameter.

    
04.07.2018 / 20:42