I'm trying to send an email to a member of our testing team when a specific file is committed to our SVN repository. I've got the post-commit
hook working properly using sendmail
with all the proper contents, but the problem is that running the sendmail
command takes ages and members of the team will complain. I've logged a message to the TortoiseSVN console letting the users know what's going on but it doesn't appear until after the mail is sent, rendering the message essentially useless.
I have two questions:
- Can I somehow make my hook output this message before
sendmail
runs? Theecho
command is beforesendmail
but it doesn't seem to do much - Can I force the
sendmail
command to run in the background?
Here is the script:
REPOS="$1"
REV="$2"
TXN_NAME="$3"
# Make sure that the log message contains some text.
SVNLOOK=/opt/bitnami/subversion/bin/svnlook
SENDMAIL=/usr/sbin/sendmail
AUTHOR=$($SVNLOOK author -r "$REV" "$REPOS")
FOUND=$($SVNLOOK changed -r "$REV" "$REPOS" | grep -Pc '[U]\s+.+(file.txt)$')
MAILLOCATION=/home/bitnami/svn/test
MAILMESSAGE="To: tester@mycorp.com\nFrom: subversion@mycorpdev\nSubject: File was modified\n\n$AUTHOR modified the file"
if [ $FOUND -eq 1 ]; then
echo "You've modified the file, yada yada yada" >&2
echo "Note: Your commit did not fail, even though the text says it did." >&2
$SENDMAIL -t < $MAILLOCATION &
exit 1
fi
exit 0
I've tried using eval $($SENDMAIL -t < $MAILLOCATION) &
and a few other things as the sendmail
command but nothing has helped.