I run a few sites on Ubuntu and I'm setting up a new deploy worflow as follows (the example uses the staging environment):
On my dev machine, I do git push staging
which pushes to a bare repository and triggers the post-receive
hook, which do these things:
- Checkout the project on a separate folder
- Backup the current deployed directory
- Deploy the files with rsync
- Set the appropriate permissions using a
post_deploy.sh
script
The above is working fine, except the permissions setting part.
Since I need to use sudo
to do a chgrp
and chown
, I tried adding the following to /etc/sudoers
:
myusername ALL=(ALL:ALL) NOPASSWD: /path/to/post_deploy.sh
But when performing the git push
I get this error:
remote: sudo: no tty present and no askpass program specified
If I run post_deploy.sh
directly from the deployed server I have no problems.
How can I run the post_deploy.sh
script from the git hook? I don't mind having to type an extra password, but from what I read the askpass thing is not for the command line (am I right?).