-1

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:

  1. Can I somehow make my hook output this message before sendmail runs? The echo command is before sendmail but it doesn't seem to do much
  2. 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.

alroc
  • 27,574
  • 6
  • 51
  • 97
Brandon
  • 4,491
  • 6
  • 38
  • 59

1 Answers1

0

You might try:

nohup $SENDMAIL -t < $MAILLOCATION &>/dev/null &
disown

Taken from here