#!/bin/sh
# chkconfig: 2345 61 39
### BEGIN INIT INFO
# Provides:          acmd
# Required-Start:    modules
# Required-Stop:     modules
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start acmd at boot time
# Description:       Enable service provided by acmd.
# X-Start-Before:    
# X-Stop-After:      
# X-Timesys-Start-Number:  61
# X-Timesys-Stop-Number:  39
### END INIT INFO

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

start() {
    pid=$(pidof $DAEMON)
    if [ -n "$pid" ]; then
      echo "$DAEMON already running"
      exit 1
    fi

    echo -n $"Starting $DAEMON daemon: "
    $DAEMON 
    RETVAL=$?
    if [ $RETVAL -ne 0 ]; then
      echo "[FAIL]"
    else
      echo "[OK]"
    fi
}

stop() {
    pid=$(pidof $DAEMON)
    if [ -z "$pid" ]; then
      echo "$DAEMON not running"
      exit 1
    fi

    echo -n $"Stopping $DAEMON daemon: "
    kill $pid
    RETVAL=$?
    if [ $RETVAL -ne 0 ]; then
      echo "[FAIL]"
    else
      echo "[OK]"
    fi
}

RETVAL=0

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart}"
        ;;
esac

exit $RETVAL
