I wrote the following script to let sa-update be run in cron. I hope it
is useful for others. When things could be done better: let me know.

    #!/usr/bin/env bash

    declare -r GREP_REGEX='not installed\|warning'
    declare -r LOG_FILE='sa-update.log'

    declare PID
    declare retVal

    cd
    sa-update -D 2>${LOG_FILE}
    retVal=${?}
    case ${retVal} in
      0)
        echo "Updated SpamAssassin rules"
        PID=$(ps aux | grep [/]spamd | awk '{ print $2 }')
        if [[ ${PID} = '' ]] ; then
          echo 'spamd is not running'
        else
          kill ${PID}
        fi
        ;;
      1)
        echo "There where no updates for SpamAssassin rules"
        ;;
      2)
        echo "There are updates, but lint check failed"
        ;;
      3)
        echo "Unknown error"
        ;;
      *)
        echo "Error while trying to download SpamAssasin rules"
        ;;
    esac
    echo
    grep "${GREP_REGEX}" ${LOG_FILE}

Off course I have in my inittab:
    spam:2345:respawn:/usr/bin/spamd --allow-tell

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Reply via email to