It's actually pretty easy to screw up your source tree:
- Update your source tree.
$ svn up
- Notice that the permissions are set to use your user — and set them to use the Apache user
$ sudo chown -R [apache user] .
- Wait a few weeks, and attempt to update your source tree.
$ svn up
foo/.svn/lock': Permission denied
Fortunately, I had a job interview a few months ago where I was asked how to fix a whole fsckload of files. I answered, "...write a script," but the answer they wanted was "use a Bash for loop." So rarely do you learn something useful from a job interview.
The next challenge came in how to fix the myriad of directories — but only those associated with subversion. I started off by attempting svn up and fixing the directories. That got old really fast.
So I started searching. After a few false starts, I came up with the following:
- Get a list of subversion directories, write to a file:
$ find . -path '*/.svn' -type d > files
- As superuser, execute a for loop on each file listed in files
$ for file in `cat files`;do chown -R [proper user] $file; done
- As normal user, test: attempt to update source tree
$ svn up
...And that was all.
(bloody hell!)
Labels: bash, find, for, linux