Advertisement
Guest User

Pipe Backend Shell Script for Dovecot Antispam Plugin

a guest
Sep 20th, 2012
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.92 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Echo-out the command that will be executed.
  4. #echo /usr/bin/sa-learn -D $* /tmp/sendmail-msg-$$.txt
  5.  
  6. # Add "starting now" string to log.
  7. echo "$$-start ($*)" >> /tmp/sa-learn-pipe.log
  8.  
  9. # Copy the message contents to a temporary text file.
  10. #echo $* > /tmp/sendmail-parms.txt
  11. cat<&0 >> /tmp/sendmail-msg-$$.txt
  12.  
  13. CURRENT_USER=$(whoami)
  14.  
  15. echo "Calling (as user $CURRENT_USER) '/usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt'" >> /tmp/sa-learn-pipe.log
  16.  
  17. # Execute sa-learn, with the passed ham/spam argument, and the temporary message contents.
  18. # Send the output to the log file while redirecting stderr to stdout (so we capture debug output).
  19. /usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt >> /tmp/sa-learn-pipe.log 2>&1
  20.  
  21. # Remove the temporary message.
  22. rm -f /tmp/sendmail-msg-$$.txt
  23.  
  24. # Add "ending now" string to log.
  25. echo "$$-end" >> /tmp/sa-learn-pipe.log
  26.  
  27. # Exit with "success" status code.
  28. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement