Last active
June 28, 2018 01:27
-
-
Save KakersUK/a3c99fb0973021bb8747 to your computer and use it in GitHub Desktop.
/etc/init.d/mailcatcher - MailCatcher init.d script for CentOS 6
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
#!/bin/bash | |
# chkconfig: 345 70 30 | |
# description: MailCatcher is a simple SMTP server to catch and display mail | |
# processname: mailcatcher | |
# Source function library. | |
. /etc/init.d/functions | |
RETVAL=0 | |
prog="/usr/local/rvm/wrappers/default/mailcatcher" | |
LOCKFILE=/var/lock/subsys/mailcatcher | |
# Declare variables for MailCatcher | |
USER=mailcatcher | |
HTTP_IP=0.0.0.0 | |
HTTP_PORT=1080 | |
SMTP_PORT=1025 | |
start() { | |
echo -n "Starting MailCatcher: " | |
daemon --user $USER $prog --http-ip $HTTP_IP --http-port $HTTP_PORT --smtp-port $SMTP_PORT --no-quit | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch $LOCKFILE | |
return $RETVAL | |
} | |
stop() { | |
echo -n "Stopping MailCatcher: " | |
killproc $prog | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE | |
return $RETVAL | |
} | |
restart() { | |
stop | |
start | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status mailcatcher | |
RETVAL=$? | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: mailcatcher {start|stop|status|restart}" | |
exit 1 | |
;; | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script assumes that on CentOS 6 you have installed a later version of ruby using RVM:
gem install mailcatcher
gem install daemons