-
-
Save davestephens/afb321663fa83c9dd0ba83a2b33e75e7 to your computer and use it in GitHub Desktop.
Mystic BBS init.d and monit configuration for Raspberry Pi
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/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 |
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
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