diff options
Diffstat (limited to 'junker.sh')
-rwxr-xr-x | junker.sh | 30 |
1 files changed, 5 insertions, 25 deletions
@@ -8,7 +8,6 @@ BASE="${HOME}"/Maildir INOTIFY='/usr/bin/inotifywait' INOTIFY_EVENTS='moved_to,moved_from' INOTIFY_OPTIONS='--monitor --recursive --event'" ${INOTIFY_EVENTS}" -LOG=/var/log/junker/${USER}.log SPAMC='/usr/bin/spamc' JUNK="${BASE}/Junk" @@ -22,22 +21,12 @@ then . "${HOME}/.junkerrc" fi -function OpenLog { - exec 3>>"${LOG}" - exec 1>&3 - exec 2>&3 - Log "Log opened" -} -function CloseLog { - Log "Log closed" - exec 3>&- -} function Log { echo -e "$( date +'%Y%m%d %H:%M:%S' )\t$@" } function Cleanup { - CloseLog + Log "Exiting" exit 0 } @@ -61,21 +50,11 @@ function Learn { exec 9<&- } -function Reload { - CloseLog - OpenLog -} - if [ ! -d "${BASE}" ] then echo "Error: Mail directory not found at ${BASE}, exiting" >&2 exit 1 fi -if [ ! -d "$( dirname ${LOG} )" ] -then - echo "Error: Log directory not found at ${LOG}, exiting" >&2 - exit 1 -fi if [ ! -x ${INOTIFY} ] then echo "Error: inotifywait not found, check path" >&2 @@ -87,14 +66,15 @@ then exit 1 fi checkfile=$( mktemp ) -${SPAMC} --learntype forget <$checkfile +echo ${RANDOM} >${checkfile} +${SPAMC} --learntype forget <${checkfile} >/dev/null 2>&1 if [ $? -eq 74 ] then echo "Error: spamd doesn't allow connections, needs --allow-tell" >&2 + rm -f ${checkfile} exit 1 fi - -OpenLog +rm -f ${checkfile} trap "Cleanup" EXIT SIGINT SIGTERM trap "Reload" SIGHUP |