Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexandre Alouit alexalouit

View GitHub Profile
@alexalouit
alexalouit / mail-reject.sh
Last active Feb 19, 2018
POSTFIX rejected mail regular email report
View mail-reject.sh
#!/bin/bash
#
# cron ex: 1 0 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/mail-reject.sh >> /root/scripts/cron.log
email=""
dir="/tmp/"
file="/var/log/mail.info"
occur="reject"
cd $dir
@alexalouit
alexalouit / mail-blocked.sh
Last active Feb 19, 2018
POSTFIX blocked mails regular email report
View mail-blocked.sh
#!/bin/bash
#
# cron ex: 1 0 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/mail-blocked.sh >> /root/scripts/cron.log
email=""
dir="/tmp/"
file="/var/log/mail.info"
occur="Blocked"
cd $dir
@alexalouit
alexalouit / mail-bounced.sh
Last active Feb 19, 2018
POSTFIX bounced mail regular email report
View mail-bounced.sh
#!/bin/bash
#
# cron ex: 1 0 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/mail-bounced.sh >> /root/scripts/cron.log
email=""
dir="/tmp/"
file="/var/log/mail.info"
occur="status=bounced"
cd $dir
@alexalouit
alexalouit / httpd-errors.sh
Last active Feb 19, 2018
HTTP errors regular email report
View httpd-errors.sh
#!/bin/bash
#
# cron ex: 1 0 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/httpd-errors.sh >> /root/scripts/cron.log
email=""
dir="/tmp/"
file="/var/log/httpd/*/error.log"
cd $dir
@alexalouit
alexalouit / mail-purge.sh
Last active Aug 28, 2017
Automatic purge of spam emails and trash that are aged 14 days over
View mail-purge.sh
#!/bin/bash
#
# cron ex: 1 0 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/mail-purge.sh >> /root/scripts/cron.log
# Search messages more than 14 days in the appropriate directories and removes
find /var/vmail/ -regex '.*/\.\(Trash\|Junk\|Deleted\ Messages\)\(/.*\)?\/\(cur\|new\)/.*' -type f -ctime +14 -delete
# Dovecot is restarted to refresh quota (to update the .quotausage file)
/etc/init.d/dovecot restart
# since version ~2.2 (need userdb iterate):
@alexalouit
alexalouit / openwrt.squid.transparent
Last active Oct 13, 2018
OpenWRT Squid transparent configuration
View openwrt.squid.transparent
Squid required:
Mount HD (15GB min) on /tmp/cache, chmod -R 777 /tmp/cache
Firewall section:
config redirect
option src 'lan'
option proto 'tcp'
option src_ip '!192.168.1.1'
option src_dport '80'
option dest_ip '192.168.1.1'
@alexalouit
alexalouit / dkim.php
Last active Aug 29, 2015
(php) DKIM test using Google.
View dkim.php
<?php
$to = "youremail@gmail.com";
$subject = "DKIM test.";
$body = "Hi,\nThis is an DKIM test.\nGo check gmail header.;
if (mail($to, $subject, $body)) {
echo("<p>Successfully sent!</p>");
} else {
echo("<p>Failed!</p>");
}
?>
@alexalouit
alexalouit / collectd-postfix-dovecot-postgrey-spf
Last active Aug 29, 2015
Collectd: Postfix, Docecot, Postgrey, SPF
View collectd-postfix-dovecot-postgrey-spf
LoadPlugin tail
<Plugin "tail">
<File "/var/log/mail.log">
Instance "postfix"
# number of connections
# (incoming)
<Match>
Regex "\\<postfix\\/smtpd\\[[0-9]+\\]: connect from\\>"
DSType "CounterInc"
View collectd-fail2ban
LoadPlugin tail
<Plugin "tail">
<File "/var/log/fail2ban.log">
Instance "fail2ban"
<Match>
Regex "Ban"
DSType "CounterInc"
Type "counter"
Instance "fail2ban-ban"
</Match>
@alexalouit
alexalouit / bind-errors.sh
Last active Feb 19, 2018
DNS (bind) errors regular email report
View bind-errors.sh
#!/bin/bash
#
# cron ex: 0 * * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/bind-errors.sh >> /root/scripts/cron.log
email=""
if [ -f /etc/bind/*.err ]
then
CONTAIN=$(ls -lah /etc/bind/*.err)
echo -e "Erreur du serveur Bind, zone:\n $CONTAIN" | mail -s "Rapport d'erreur Bind" $email