diff --git a/.gitignore b/.gitignore index b12dda2..211e737 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ +# Ignore the compiled binary mailq-inspector + +# Ignore .vagrant folder +.vagrant diff --git a/Vagrantfile b/Vagrantfile index bc2a198..e0db4d3 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -7,7 +7,33 @@ Vagrant.configure("2") do |config| config.vm.synced_folder "./", "/vagrant", type: "rsync" config.vm.provision "shell", inline: <<-SHELL + # Basic preparations apt-get update - apt-get install -y postfix + + # Install postfix + DEBIAN_FRONTEND=noninteractive apt-get install -y postfix + + # Enable and launch postfix + systemctl enable postfix.service + systemctl start postfix.service + + # Block port 25 for IPv4 + iptables -A INPUT -p tcp --dport 25 -j DROP + iptables -A FORWARD -p tcp --dport 25 -j DROP + iptables -A OUTPUT -p tcp --dport 25 -j DROP + + # Block port 25 for IPv6 + ip6tables -A INPUT -p tcp --dport 25 -j DROP + ip6tables -A FORWARD -p tcp --dport 25 -j DROP + ip6tables -A OUTPUT -p tcp --dport 25 -j DROP + + # Install mailutils (tools to send mail) + apt-get install -y mailutils + + # Invoke script that sends test mails, so we have test data + /vagrant/vagrant-util/send-test-mails.sh --LETS-REALLY-DO-THIS-AND-SEND-MAIL + + # That's it + echo "That's it. We're set up. Enjoy your test environment." SHELL end diff --git a/vagrant-util/send-test-mails.sh b/vagrant-util/send-test-mails.sh new file mode 100755 index 0000000..18b64dc --- /dev/null +++ b/vagrant-util/send-test-mails.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# This script is supposed to be run within a shielded* vagrant environment. +# It's job is to send a bunch of test emails, for testing purposes. +# If you really intend to run this on your own, you need to pass the flag +# --LETS-REALLY-DO-THIS-AND-SEND-MAIL to it. +# +# I don't want this script to do damage. +if [[ "$1" != "--LETS-REALLY-DO-THIS-AND-SEND-MAIL" ]]; then + echo "WORD OF WARNING" + echo + echo "DO NOT RUN THIS OUT OF A SHIELDED VAGRANT BOX!" + echo "TO PROCEED RUNNING THIS TOOL, PROVIDE THE ARGUMENT" + echo "--LETS-REALLY-DO-THIS-AND-SEND-MAIL" + exit 1; +fi + +echo "LOL" | mail -s "Testmail" jpt@jpt.lu