#!/bin/bash                                 
### BEGIN INIT INFO                            
# Provides: sixad
# Required-Start:    $local_fs $syslog $remote_fs dbus
# Required-Stop:     $local_fs $syslog $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start sixad
### END INIT INFO
#                                                                    
# Author:       falkTX <falktx@gmail.com>                     
#                                                                    
# set -e 

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/bin/sixad

sixad_already_running_check () {
ps -e | grep sixad-bin > /dev/null
}

. /lib/lsb/init-functions

case "$1" in
  start)
if (sixad_already_running_check "$1"); then
  log_warning_msg "sixad is already running"
else
{
  log_daemon_msg "Starting sixad"
  $DAEMON --start &
  log_end_msg 0
}
fi
    ;;
  stop)
    if (sixad_already_running_check "$1"); then
    {
      log_daemon_msg "Stopping sixad"
      $DAEMON --stop || true
      log_end_msg 0
    }
    else
      log_warning_msg "sixad is not running"
    fi
    ;;
  restart|force-reload)
    $0 stop
    $0 start
    ;;
  status)
    status_of_proc "sixad-bin" "sixad" && exit 0 || exit $?
    ;;
  *)
    echo "Usage: /etc/init.d/sixad {start|stop|restart|force-reload|status}" >&2
    exit 1
    ;;
esac

exit 0
