I have written my first shell script which goes like this
#!/bin/bash
#
# This is a custom post-commit for sending email
# when an svn repo is changed.
#
repodir=$1
revision=$2
author=`/usr/bin/svnlook author -r $revision $repodir`
date=`/usr/bin/svnlook date -r $revision $repodir`
log=`/usr/bin/svnlook log -r $revision $repodir`
info=`/usr/bin/svnlook changed -r $revision $repodir`
url="http://www.mydomain.net/svn/filesystem/$repo"
echo 'To: me@googlemail.com' > commit-message **<<LINE17**
echo 'From: me@mydomain.net' >> commit-message
echo 'Subject: SVN Commit' >> commit-message
echo '' >> commit-message
echo 'repository - $url' >> commit-message
echo 'date - $date' >> commit-message
echo 'username - $author' >> commit-message
echo 'revision - $revision' >> commit-message
echo 'comment - $log' >> commit-message
echo 'test email' >> commit-message
echo '$info' >> commit-message
ssmtp me@googlemail.com < commit-message
rm commit-message
When i run a test (with the svn vars stripped out) logged in as me on the server: ./post-commit
The script runs fine, it writes the commit file to disk and uses in conjunction with sSMTP, and i receive an email in gmail.
However when I commit a file with svn I am getting permission errors.
The thing is I have chmod'd the parent dir to 777.
post-commit hook failed (exit code 1) with output:
/home/svn/filesystem/hooks/post-commit: line 17: commit-message: Permission denied
When I try to see which user is running commits by wiping the post-commit script to:
echo $USER
It doesn't return anything.