Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #export PATH=$PATH:/usr/lib/dovecot
- #MYENV=$(env)
- # Add "starting now" string to log.
- echo "$$-start ($*)" >> /tmp/sa-learn-pipe.log
- #echo "ENV value is: $MYENV" >> /tmp/sa-learn-pipe.log
- #echo "PATH value is: $PATH" >> /tmp/sa-learn-pipe.log
- CURRENT_USER=$(whoami)
- #echo $* > /tmp/sendmail-parms.txt
- # Copy the message contents to a temporary text file.
- #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@example.com\" -m \"Training.$mode\" -p \"/tmp/sendmail-msg-$$.txt\"'" >> /tmp/sa-learn-pipe.log
- # options from http://wiki.dovecot.org/LDA
- #strace -f -F /usr/lib/dovecot/deliver -d "sa-training@example.com" -m "Training.$mode" -p "/tmp/sendmail-msg-$$.txt" >>/tmp/strace.txt 2>&1
- /usr/lib/dovecot/deliver -d "sa-training@example.com" -m "Training.$mode"
- echo "Exit status was $?" >> /tmp/sa-learn-pipe.log
- 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