Skip to content

Instantly share code, notes, and snippets.

@tknr
Last active May 16, 2018 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tknr/aebf61f161ae06c3d71e8d22bd6c788c to your computer and use it in GitHub Desktop.
Save tknr/aebf61f161ae06c3d71e8d22bd6c788c to your computer and use it in GitHub Desktop.
#! /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