Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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/sh

echo
echo "**** Pulling changes into Prime [Hub's post-update hook]"
echo
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?

share|improve this question

1 Answer 1

up vote 7 down vote accepted

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).

share|improve this answer
    
That did it. Thanks. –  Ian Apr 14 '13 at 3:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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