Based on this Serverfault question, my git user has permission in sudoers to run a wrapper script to move files into my webroot with git.

Everything is working fine except for the chmod and chown lines. After the script has run, the files are still root:root instead of apache:apache.


echo "**** Pulling changes into Prime [Hub's post-update hook]"
cd /usr/local/apache/htdocs || exit
unset GIT_DIR
git pull hub master
exec /usr/libexec/git-core/git-update-server-info
chmod -R 0644 /usr/local/apache/htdocs
chown -R apache:apache /usr/local/apache/htdocs

Since the script is running as root, why wouldn't the chmod and chown commands be working?


The chmod line is never reached as you can easily check by inserting touch /root/checkfile directly above. exec does not return into the script. I must be the last command in a script (or script's branch).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.