Skip to content

Instantly share code, notes, and snippets.

@EHLOVader
Forked from dakatsuka/mailcatcher.sh
Last active July 26, 2016 14:25
Show Gist options
  • Save EHLOVader/9233230 to your computer and use it in GitHub Desktop.
Save EHLOVader/9233230 to your computer and use it in GitHub Desktop.
#!/bin/bash
PID_FILE=/var/run/mailcatcher.pid
NAME=mailcatcher
PROG="/usr/bin/env mailcatcher"
USER=mailcatcher
GROUP=mailcatcher
start() {
echo -n "Starting MailCatcher"
if start-stop-daemon --stop --quiet --pidfile $PID_FILE --signal 0
then
echo " already running."
exit
fi
start-stop-daemon \
--start \
--pidfile $PID_FILE \
--make-pidfile \
--background \
--exec $PROG \
--user $USER \
--group $GROUP \
--chuid $USER \
-- \
--foreground \
--http-ip=0.0.0.0 \
--http-port=1080 \
--smtp-port=1025
echo "."
return $?
}
stop() {
echo -n "Stopping MailCatcher"
start-stop-daemon \
--stop \
--oknodo \
--pidfile $PID_FILE
echo "."
return $?
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
@leventyalcin
Copy link

/etc/init.d/mailcatcher stop tries to start mailcatcher and PROG=/usr/bin/env mailcatcher should be PROG="/usr/bin/env mailcatcher"

root@vagrant:/etc/init.d# /etc/init.d/mailcatcher stop
+ PID_FILE=/var/run/mailcatcher.pid
+ NAME=mailcatcher
+ PROG=/usr/bin/env
+ mailcatcher
Starting MailCatcher
~~> ERROR: Something's using port 1025. Are you already running MailCatcher?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment