#!/bin/sh
### BEGIN INIT INFO
# Provides:          octopussy
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/Stop Octopussy programs
### END INIT INFO

### BEGIN CHKCONFIG INFO
# chkconfig: 2345 90 50
# description: Start/Stop Octopussy programs
### END CHKCONFIG INFO

DESC="Octopussy"

. /lib/lsb/init-functions

# Create octopussy log directory and
# file and set permissions so this script
# can be run by octopussy user.
if [ ! -d /var/log/octopussy ]; then
	mkdir -p /var/log/octopussy
	touch /var/log/octopussy/octopussy.log
    chown -R octopussy:octopussy /var/log/octopussy
fi

case "$1" in
  start)
    log_begin_msg "Starting $DESC"
    /usr/sbin/octopussy start >> /var/log/octopussy/octopussy.log 2>&1
    log_end_msg $?
    ;;
  stop)
    log_begin_msg "Stopping $DESC"
    /usr/sbin/octopussy stop >> /var/log/octopussy/octopussy.log 2>&1
    log_end_msg $?
    ;;
  restart|force-reload)
    log_begin_msg "Restarting $DESC"
    /usr/sbin/octopussy restart >> /var/log/octopussy/octopussy.log 2>&1
    log_end_msg $?
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|force-reload}" >&2
    exit 1
    ;;
esac

exit 0
