#!/bin/sh #---------------------------------------------------------------------------------- # /var/install/bin/antispam-add-address-to-whitelist - add address to awl whitelist # # Copyright (c) 2001-2024 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2012-06-24 jed # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------------- # read eislib . /var/install/include/eislib #exec 2>/tmp/antispam-add-address-to-whitelist-trace-$$.log #set -x pgmname=`basename $0` case ${pgmname} in antispam-add-address-to-blacklist) awl_name=blacklist ;; antispam-add-address-to-whitelist|*) awl_name=whitelist ;; esac configfile=/etc/config.d/antispam clrhome mecho --info "Antispam add address to '${awl_name}'" mecho if [ -f ${configfile} ] then # read configuration . ${configfile} if [ "${START_ANTISPAM}" = "yes" ] then if [ "${ANTISPAM_AUTO_WHITELIST}" = "yes" ] then as_exit=0 until [ ${as_exit} -eq 1 ] do /var/install/bin/ask "Please enter an email address to add, (q)uit:" '' '+' > /tmp/ask.$$ rc=$? address=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ ${rc} = 255 ] then exit 1 fi case ${address} in q|Q) # quit as_exit=1 ;; * ) # address entered, check syntax echo "${address}" | grep -q -E "[[:alnum:].-]@[[:alnum:].-]+\.[[:alnum:]]+$" if [ $? -eq 0 ] then # address syntax ok, add it to awl # echo "exec: spamassassin --add-addr-to-${awl_name}=\"${address}\"" spamassassin --add-addr-to-${awl_name}="${address}" if [ $? -eq 0 ] then echo "done." echo if /var/install/bin/ask "Do you want to add another address" 'n' then clrhome mecho --info "Antispam add address to '${awl_name}'" mecho else as_exit=1 fi fi else # invalid address syntax mecho --warn "invalid address syntax, try it again!" anykey fi ;; esac done else mecho --warn "Antispam auto-whitelist function is currently disabled!" fi else mecho --warn "Antispam package is currently disabled!" fi else mecho --error "Configuration file '${configfile}' doesn't exist!" fi exit 0