Reputation: 5900
I am using https://laravel.com/docs/5.4/envoy as a deployment tool. In the Envoy.blade.php, I have command that requires sudo access for example:-
chmod 777 -R storage/
chmod 777 -R bootstrap/cache
These commands fails with an error saying operation not permitted. How can we resolve this?
Upvotes: 3
Views: 1565
Reputation: 518
I changed the following configuration on the server
sudo visudo
and add
username ALL=(ALL) NOPASSWD: ALL
All commands can now be executed without entering a password
You can also specify individual commands
username ALL=(username) NOPASSWD:/etc/init.d/apache2 reload
Upvotes: 5
Reputation: 550
To run those commands as sudo try the following:
echo "{{ $password }}" | sudo -S chmod 777 -R storage/
echo "{{ $password }}" | sudo -S chmod 777 -R bootstrap/cache
Obviously you'll need to pass the sudo password into the envoy run command.
envoy run mytask --password=mypass
Tested on Ubuntu server 16.04 & 17.04
Upvotes: 4