Prepare skeleton to build a very basic test environment

This commit is contained in:
Jan Philipp Timme 2019-01-26 11:38:32 +01:00
parent e20b956911
commit 5db1b891f1
3 changed files with 49 additions and 1 deletions

4
.gitignore vendored
View File

@ -1 +1,5 @@
# Ignore the compiled binary
mailq-inspector mailq-inspector
# Ignore .vagrant folder
.vagrant

28
Vagrantfile vendored
View File

@ -7,7 +7,33 @@ Vagrant.configure("2") do |config|
config.vm.synced_folder "./", "/vagrant", type: "rsync" config.vm.synced_folder "./", "/vagrant", type: "rsync"
config.vm.provision "shell", inline: <<-SHELL config.vm.provision "shell", inline: <<-SHELL
# Basic preparations
apt-get update 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 SHELL
end end

18
vagrant-util/send-test-mails.sh Executable file
View File

@ -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