3

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?

Dipendra Gurung
  • 5,720
  • 11
  • 39
  • 62

2 Answers2

4

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
Sergey Andrianov
  • 508
  • 1
  • 4
  • 13
3

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

Dave Carruthers
  • 542
  • 1
  • 8
  • 29