Create a gist now

Instantly share code, notes, and snippets.

@tknr /maildev
Last active May 16, 2018

What would you like to do?
#! /bin/bash
### BEGIN INIT INFO
# Provides: maildev
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Maildev
# Description: This file starts and stops Maildev server
#
### END INIT INFO
# /etc/init.d/maildev
case "$1" in
start)
$(which maildev) -s 1025 -w 1080 &
;;
stop)
kill -9 $(ps ax |grep $(which maildev) |grep -v grep |awk '{print $1}') 2> /dev/null
sleep 1
;;
restart)
kill -9 $(ps ax |grep $(which maildev) |grep -v grep |awk '{print $1}') 2> /dev/null
sleep 2
$(which maildev) -s 1025 -w 1080 &
;;
status)
ps ax |grep $(which maildev) |grep -v grep > /dev/null
if [ $? = 0 ]; then
echo maildev is running.
else
echo maildev is not running.
fi
;;
*)
echo "Usage: maildev {start|stop|restart}" >&2
exit 3
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment