Skip to content

Instantly share code, notes, and snippets.

@davestephens
Last active November 25, 2019 01:39
Show Gist options
  • Save davestephens/afb321663fa83c9dd0ba83a2b33e75e7 to your computer and use it in GitHub Desktop.
Save davestephens/afb321663fa83c9dd0ba83a2b33e75e7 to your computer and use it in GitHub Desktop.

Revisions

  1. davestephens revised this gist Jun 27, 2016. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions mis
    Original file line number Diff line number Diff line change
    @@ -23,11 +23,7 @@ DESC="mystic internet server"
    MIS_OPTS=
    PID="$MYSTICINSTALLPATH/semaphore/$NAME.bsy"

    echo $PID
    echo $DAEMON


    # Check if DAEMON binary exist
    # Check if DAEMON binary exists
    [ -f $DAEMON ] || exit 0

    [ -f "/etc/default/$NAME" ] && . /etc/default/$NAME
  2. davestephens renamed this gist Jun 27, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. davestephens created this gist Jun 27, 2016.
    74 changes: 74 additions & 0 deletions init.d
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,74 @@
    #!/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"

    echo $PID
    echo $DAEMON


    # Check if DAEMON binary exist
    [ -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
    6 changes: 6 additions & 0 deletions mystic.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    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