From b8534de6e47e8c9bab6d65edf2665eab8cedcaf5 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Thu, 19 Jan 2017 18:36:59 +0100 Subject: [PATCH] fix purge script --- README.md | 16 ++++++++++------ cron/purge.sh | 30 +++++++++++++++--------------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 5035dd2..91eeced 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Trash-email-alias A dovecot sieve 's script and configuration to generate a temporary random alias. +Read more on my blog (french) https://blog-du-grouik.tinad.fr/post/2017/01/18/Alias-mail-temporaire + # Usage Just send an email to the configured em-mail generator. It will respond you and indicate what is your alias. You can test it by sending a mail to [ getalias Arobaze tinad.fr ]. @@ -47,9 +49,11 @@ On /etc/dovecot/dovecot.conf my plugin section looks like: (...) } - Change your mysql credentials on cron/purge.sh and execute/genalias.sh - In my case, this files are owned by the unix user "dovecot". - - Add purge.sh on your crontab. Every 10 minutes is enougth. - - Add the filters on yours sieve rules. Sample on this repo ./global.sieve file. +Copy this repo's files where they're needed ;) + +Change your mysql credentials on cron/purge.sh and execute/genalias.sh +In my case, this files are owned by the unix user "dovecot". + +Add purge.sh on your crontab. Every 10 minutes is enougth. + +Add the filters on yours sieve rules. Sample on this repo ./global.sieve file. diff --git a/cron/purge.sh b/cron/purge.sh index ef40068..8004165 100755 --- a/cron/purge.sh +++ b/cron/purge.sh @@ -1,24 +1,24 @@ #!/bin/bash -#Gnieark https://blog-du-grouik.tinad.fr 2017 +#Gnieark https://blog-du-grouik.tinad.fr 2017 #GNU GPL V2 license -#inactivate alias olders than on +#inactivate alias olders than on MYSQLPATH="/usr/bin/mysql" -MYSQLDB="postfix" +MYSQLDB="postfix" MYSQLUSER="postfix" -MYSQLPWD="******" +MYSQLPWD="******" LOGGERPATH="/usr/bin/logger" -LOGFILE="/var/log/genalias.log" +LOGFILE="/var/log/genalias.log" +DOMAIN="tinad.fr" +TTL="3600" -TTL="3600" - -$MYSQLPATH -u $MYSQLUSER -p$MYSQLPWD $MYSQLDB<< EOF +$MYSQLPATH -u $MYSQLUSER -p$MYSQLPWD $MYSQLDB<< EOF UPDATE alias - SET active='0' - WHERE DOMAIN='tinad.fr' - AND active = '1' - AND created < (UNIX_TIMESTAMP() - $TTL) - AND temporary='1'; + SET active='0' + WHERE DOMAIN='$DOMAIN' + AND active = '1' + AND modified > (UNIX_TIMESTAMP() - $TTL) + AND temporary='1'; EOF - + $LOGGERPATH -s "Inactivate temporary alias older than 1 hour" 2> $LOGFILE -exit 0 \ No newline at end of file +exit 0 \ No newline at end of file