Skip to content

Instantly share code, notes, and snippets.

View alexalouit's full-sized avatar

Alexandre Alouit alexalouit

View GitHub Profile
@alexalouit
alexalouit / mail-reject.sh
Last active February 19, 2018 10:21
POSTFIX rejected mail regular email report
#!/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 February 19, 2018 10:22
POSTFIX blocked mails regular email report
#!/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 February 19, 2018 10:22
POSTFIX bounced mail regular email report
#!/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 February 19, 2018 10:22
HTTP errors regular email report
#!/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 August 28, 2017 08:35
Automatic purge of spam emails and trash that are aged 14 days over
#!/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 April 11, 2022 21:25
OpenWRT Squid transparent configuration
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 August 29, 2015 14:06
(php) DKIM test using Google.
<?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 August 29, 2015 14:06
Collectd: Postfix, Docecot, 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"
@alexalouit
alexalouit / collectd-fail2ban
Created September 9, 2014 13:58
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 February 19, 2018 10:22
DNS (bind) errors regular email report
#!/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