#!/bin/sh
#
#

# 3dm2:     	Starts the 3ware 3DM2 daemon
#
# Author:       Michael Benz <linuxraid@lsi.com>
#
# description: Start the 3DM2 daemon which logs the current state
#              of the 3ware controller, and then polls for state
#              changes.
#

# processname: 3dm2
# config: /etc/3dm2/3dm2.conf

# PROVIDE: 3DM2
# REQUIRE: DAEMON
# BEFORE:  LOGIN
# KEYWORD: FreeBSD

. /etc/rc.subr

name="tdm2"
command="/usr/sbin/3dm2"
stop_cmd="stop_tdm2"
status_cmd="status_tdm2"

stop_tdm2()
{
	rc_pid=$(check_process $command)
	if [ -z "$rc_pid" ]; then
		[ -n "${rc_force}" ] && return 0
		_run_rc_notrunning
		return 1
	fi
	echo -n "Stopping 3ware DiskSwitch daemon (pid:$rc_pid): "
	kill -QUIT $rc_pid
	kill -QUIT $rc_pid
}

status_tdm2()
{
	rc_pid=$(check_process $command)
	if [ -n "$rc_pid" ]; then
		echo "${name} is running as pid $rc_pid."
	else
		echo "${name} is not running."
	fi
}

load_rc_config $name
run_rc_command "$1"
