0

I set a CentOS to run our company website using Apache. Apache runs as user apache. Now, to update our website code using git, I set a user say sumit, and create a shell script that does git pull (I think we can use rsync, but I am not sure how to use it).

Now, I set this shell script to run in timely manner, and it works fine. however when it download the changes it change the owner of file form apache:apache to sumit:sumit as that is the user it download with. I try to put chown in my shell script but it doesn't change user as it requires sudo user.

How can I ensure that using git 1. I can manage permission (so all writable folder do not change or stick to my need) 2. new files that get downloaded remain for apache.

Oh, I did try to run cron using apache user, but that didn't work as apache is banned from shell.

1 Answer 1

0

Your problem here is that you're using git as a deployment tool, which is isn't. Git is for version control, and that's it. When you want to deploy your code somewhere, you should be using either a script or a pre-built product to check out the right branch, copy relevant files, compile anything that might need compiling, and, in your case, set permissions.

There's a number of ways you could do this. There are commercial build servers like TeamCity or Jenkins/Hudson (and many more similar) which have all kinds of built-in functionality for deployment.

Alternatively, you could use a git hook on your git server to call a script which does the copy and permission setting for you. This hook would need to run as a user which has the correct permissions to chown/chmod obviously, but you could achieve this securely with ssh keys.

1
  • Well, my project is in PHP, and it doesn't need compilation. using GIT is just to ensure we have controlled version of script that goes on server, I can setup FTP, but it doesn't give version of script on server. For Permission yes we can run a script, like my current user, but what permission should I gave to that user in order for it to work without doing suo. Feb 5, 2016 at 7:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .