Created
June 16, 2018 00:16
-
-
Save kafene/5e3d3a28cd7a5eac050dbdd1b22df9e3 to your computer and use it in GitHub Desktop.
Install Mailhog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
if [[ -f /usr/local/bin/mailhog ]]; then | |
echo 'It seems mailhog is already installed.' >&2 | |
echo 'Remove </usr/local/bin/mailhog> to force reinstallation.' >&2 | |
exit 1 | |
fi | |
if [[ "$EUID" -ne 0 ]]; then | |
echo 'This script must be run with root privileges (hint: use sudo)' >&2 | |
exit 1 | |
fi | |
echo 'Installing Mailhog...' | |
# These can be overridden using environment variables if needed | |
# e.g. `DOWNLOAD_URL=http://example.com/mailhog_v2.0 /path/to/mailhog-install.sh` | |
download_url="${DOWNLOAD_URL:-https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64}" | |
install_path="${INSTALL_PATH:-/usr/local/bin/mailhog}" | |
curl -LSso "$install_path" "$download_url" | |
chmod +x /usr/local/bin/mailhog | |
cat > /etc/systemd/system/mailhog.service <<EOF | |
[Unit] | |
Description=Mailhog | |
After=network.target | |
[Service] | |
Type=simple | |
ExecStart=/usr/bin/env /usr/local/bin/mailhog > /dev/null 2>&1 & | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
systemctl daemon-reload | |
systemctl enable mailhog | |
systemctl start mailhog | |
systemctl status mailhog | |
# Something like this might be necessary to allow outside access. | |
# It will depend on what firewall you're using but this is just | |
# an example with ufw, to allow access to the web interface: | |
# ufw allow out 8025 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment