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.#!/bin/shechoecho **** Pulling changes into Prime [Hub's post-update hook]echocd /usr/local/apache/htdocs || exitunset GIT_DIRgit pull hub masterexec /usr/libexec/git-core/git-update-server-infochmod -R 0644 /usr/local/apache/htdocschown -R apache:apache /usr/local/apache/htdocsSince the script is running as root, why wouldn't the chmod and chown commands be working?
chmod and chown not working in sudo called script
shell script;sudo;chmod;chown
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).