Created
April 15, 2019 08:26
-
-
Save aepnat/d0c6bd5e3ad7e55219c66e4c9e8e344f to your computer and use it in GitHub Desktop.
Installation of MailHog on CentOS
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
#!/bin/sh | |
# /etc/init.d/mailhog | |
# | |
# MailHog init script. | |
# | |
# @author Jeff Geerling | |
### BEGIN INIT INFO | |
# Provides: mailhog | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start MailHog at boot time. | |
# Description: Enable MailHog. | |
### END INIT INFO | |
PID=/var/run/mailhog.pid | |
LOCK=/var/lock/mailhog.lock | |
USER=nobody | |
BIN=/usr/sbin/mailhog | |
DAEMONIZE_BIN=/usr/sbin/daemonize | |
AUTH="-auth-file=/etc/mailhog/passwd" | |
# Carry out specific functions when asked to by the system | |
case "$1" in | |
start) | |
echo "Starting mailhog." | |
$DAEMONIZE_BIN -p $PID -l $LOCK -u $USER $BIN $AUTH | |
;; | |
stop) | |
if [ -f $PID ]; then | |
echo "Stopping mailhog."; | |
kill -TERM $(cat $PID); | |
rm -f $PID; | |
else | |
echo "MailHog is not running."; | |
fi | |
;; | |
restart) | |
echo "Restarting mailhog." | |
if [ -f $PID ]; then | |
kill -TERM $(cat $PID); | |
rm -f $PID; | |
fi | |
$DAEMONIZE_BIN -p $PID -l $LOCK -u $USER $BIN $AUTH | |
;; | |
status) | |
if [ -f $PID ]; then | |
echo "MailHog is running."; | |
else | |
echo "MailHog is not running."; | |
exit 3 | |
fi | |
;; | |
*) | |
echo "Usage: /etc/init.d/mailhog {start|stop|status|restart}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
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
## Install packages | |
sudo yum install wget curl vim epel-release | |
sudo yum install daemonize.x86_64 | |
## Install mailhog | |
wget https://github.com/mailhog/MailHog/releases/download/v0.2.0/MailHog_linux_amd64 | |
sudo chmod +x MailHog_linux_amd64 | |
sudo chown root:root MailHog_linux_amd64 | |
sudo mv MailHog_linux_amd64 /usr/sbin/mailhog | |
## Install mailhog initd service | |
wget https://raw.githubusercontent.com/geerlingguy/ansible-role-mailhog/master/templates/mailhog.init.j2 | |
sudo chown root:root mailhog.init.j2 | |
sudo chmod +x mailhog.init.j2 | |
sudo mv mailhog.init.j2 /etc/init.d/mailhog | |
### Fix the paths in the mailhog init.d file | |
sudo vim /etc/init.d/mailhog | |
## Start mailhog | |
sudo chkconfig mailhog on | |
sudo service mailhog start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment