trash-email-alias/cron/purge.sh
2017-01-17 07:50:54 +01:00

24 lines
547 B
Bash
Executable File

#!/bin/bash
#Gnieark https://blog-du-grouik.tinad.fr 2017
#GNU GPL V2 license
#inactivate alias olders than on
MYSQLPATH="/usr/bin/mysql"
MYSQLDB="postfix"
MYSQLUSER="postfix"
MYSQLPWD="******"
LOGGERPATH="/usr/bin/logger"
LOGFILE="/var/log/genalias.log"
TTL="3600"
$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';
EOF
$LOGGERPATH -s "Inactivate temporary alias older than 1 hour" 2> $LOGFILE
exit 0