#! /bin/sh
# vim:tabstop=4:softtabstop=0:shiftwidth=4 

#=============================================================================|
#                *** PROPRIETARY RIGHTS NOTICE ***                            |
#   This material contains proprietary information of MULI Holdings P/L,      |
#   Wahroonga, NSW, Australia and/or its licensor, embodying                  |
#   "CONFIDENTIAL INFORMATION" ideas and expressions, no part of which may    |
#   be reproduced or transmitted without permission of MULI Management P/L.   |
#      ***  COPYRIGHT  1982 - 2013  ***  MULI Holdings P/L  ***               |
#                          All rights reserved.                               |
#=============================================================================|

### BEGIN INIT INFO
# Provides: muli_broadway_service
# required-start: $network $named $remote_fs
# required-stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Muli Broadway Service startup script
# Description: Muli Broadway Service startup script
### END INIT INFO

export PATH=$PATH:/usr/local/muli/bin:/usr/local/muli/scripts

PPATH=/usr/local/muli

NGINX=nginx
NGINX_DAEMON=/usr/local/bin/nginx
NGINX_DAEMON_OPTS="-p $PPATH/nginx/ -c conf/nginx.conf"
NGINX_PIDFILE=$PPATH/$NGINX/logs/$NGINX.pid

test -x $NGINX_DAEMON || exit 0

. /lib/lsb/init-functions

start() {
    muli_start_app_all &>/dev/null
}

stop() {
    muli_stop_app_all
}

if [ "$(id -u)" != "0" ]; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

case "$1" in
    start)
	start
	;;
    stop)
        stop
	;;
    reload|restart|force-reload)
        stop
	sleep 1
        start
	;;
    *)
        echo "Usage: $0 {start|stop|reload}" 1>&2
        exit 1
	;;
esac

exit 0
