#!/usr/bin/env zsh # # Copyright © 2011 Nick Bowler # # Check mail for spam, automatically spawning spamd as necessary. This # script can therefore be used in a procmail recipe to efficiently handle # spam filtering. # # Runs plain old spamassassin if the daemon cannot be started for any reason. # # License WTFPL2: Do What The Fuck You Want To Public License, version 2. # This is free software: you are free to do what the fuck you want to. # There is NO WARRANTY, to the extent permitted by law. spamd_sock=$HOME/.spamd spamd_log=$HOME/.spamdlog spamd_pid=$HOME/.spamdpid spamd=/usr/sbin/spamd run_spamd() { flock -n $spamd_pid $spamd --pidfile=$spamd_pid --syslog=$spamd_log \ --socketpath=$spamd_sock $@ } if ! spamc -K -U $spamd_sock &>/dev/null; then run_spamd --daemonize || exec spamassassin fi exec spamc -U $spamd_sock