Skip to content

Instantly share code, notes, and snippets.

@davestephens
Last active November 25, 2019 01:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davestephens/afb321663fa83c9dd0ba83a2b33e75e7 to your computer and use it in GitHub Desktop.
Save davestephens/afb321663fa83c9dd0ba83a2b33e75e7 to your computer and use it in GitHub Desktop.
Mystic BBS init.d and monit configuration for Raspberry Pi
#!/bin/sh
### BEGIN INIT INFO
# Provides: mis
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Should-Start: $all
# Should-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Mystic Internet Server
# Description: mis is the launcher for Mystic's Internet Servers
### END INIT INFO
set -e
. /lib/lsb/init-functions
MYSTICINSTALLPATH=/mystic
DAEMON=$MYSTICINSTALLPATH/mis
NAME=mis
DESC="mystic internet server"
MIS_OPTS=
PID="$MYSTICINSTALLPATH/semaphore/$NAME.bsy"
# Check if DAEMON binary exists
[ -f $DAEMON ] || exit 0
[ -f "/etc/default/$NAME" ] && . /etc/default/$NAME
MIS_OPTS="-d"
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
if start-stop-daemon -d $MYSTICINSTALLPATH --start --quiet --pidfile $PID --exec $DAEMON -- $MIS_OPTS 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
if start-stop-daemon --retry TERM/5/KILL/5 --stop --quiet --pidfile $PID 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
restart)
log_daemon_msg "Restarting $DESC" "$NAME"
start-stop-daemon --retry TERM/5/KILL/5 --stop --quiet --pidfile $PID 1>/dev/null
if start-stop-daemon -d $MYSTICINSTALLPATH --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $MIS_OPTS 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
status)
status_of_proc -p $PID $DAEMON $NAME
;;
*)
log_action_msg "Usage: /etc/init.d/$NAME {start|stop|restart|status}"
;;
esac
exit 0
check process mystic with pidfile /mystic/semaphore/mis.bsy
group mystic
start program = "/etc/init.d/mis start"
stop program = "/etc/init.d/mis stop"
if failed host 127.0.0.1 port 23 type tcp then restart
if 5 restarts within 5 cycles then timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment