Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Add "starting now" string to log.
- echo "$$-start ($*)" >> /tmp/sa-learn-pipe.log
- CURRENT_USER=$(whoami)
- # Copy the message contents to a temporary text file.
- #echo $* > /tmp/sendmail-parms.txt
- cat<&0 >> /tmp/sendmail-msg-$$.txt
- mode=
- for opt; do
- echo "Checking if the command-line input argument string ($*) contains the string \"ham\" or \"spam\"" >> /tmp/sa-learn-pipe.log
- if [[ "$*" =~ .*ham.* ]]
- then
- mode=HAM
- break
- elif [[ "$*" =~ .*spam.* ]]
- then
- mode=SPAM
- break
- else
- echo "Mode (HAM or SPAM) cannot be determined from command-line arguments; check the calling script" >> /tmp/sa-learn-pipe.log
- exit 0
- fi
- done
- echo "Mode is \"$mode\"" >> /tmp/sa-learn-pipe.log
- if test -n "$mode"; then
- echo "Calling (as user $CURRENT_USER) '/usr/lib/dovecot/deliver -d \"sa-training@dv.level8ds.com\" -m \"Training.$mode\" -p \"/tmp/sendmail-msg-$$.txt\"'" >> /tmp/sa-learn-pipe.log
- # options from http://wiki.dovecot.org/LDA
- /usr/lib/dovecot/deliver -d "sa-training@example.com" -m "Training.$mode" -p "/tmp/sendmail-msg-$$.txt"
- fi
- # Remove the temporary message.
- rm -f /tmp/sendmail-msg-$$.txt
- # Add "ending now" string to log.
- echo "$$-end" >> /tmp/sa-learn-pipe.log
- # Exit with "success" status code.
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement