Last active
July 8, 2019 06:31
-
-
Save DamionDamion/c3b2f26a0e3adf3a00474be6391a112e to your computer and use it in GitHub Desktop.
MailHog Standalone Installation / Systemd service script
This file contains hidden or 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
# -r, --system create a system account | |
# -m, --create-home create the user's home directory (by default no home created for system accounts) | |
# -s, --shell SHELL login shell of the new account (Do system accounts get nologin by default anyway?) | |
sudo useradd -r -m -s /usr/sbin/nologin mailhog | |
# https://github.com/mailhog/MailHog/releases | |
wget https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64 -O /home/mailhog/MailHog_linux_amd64 | |
# make exec. | |
# I like to keep the binary non-writeable by the executing user. | |
chmod +x /home/mailhog/MailHog_linux_amd64 | |
# Optional, lets this specific binary listen to privilaged ports (ie 25) while running as an un-privilaged user. | |
setcap CAP_NET_BIND_SERVICE=+eip /home/mailhog/MailHog_linux_amd64 | |
# create systemd service file | |
echo "[Unit] | |
Description=MailHog Email Catcher | |
After=syslog.target network.target | |
[Service] | |
User=mailhog | |
Group=mailhog | |
Environment=MH_API_BIND_ADDR=0.0.0.0:80 | |
Environment=MH_UI_BIND_ADDR=0.0.0.0:80 | |
Environment=MH_SMTP_BIND_ADDR=0.0.0.0:25 | |
Type=simple | |
ExecStart=/home/mailhog/MailHog_linux_amd64 | |
StandardOutput=journal | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target" > /etc/systemd/system/mailhog.service | |
# enable and start the service | |
systemctl enable mailhog | |
systemctl start mailhog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yeet