#!/bin/sh
#
# $FreeBSD: ports/sysutils/consolekit/files/consolekit.in,v 1.1 2007/08/27 13:52:48 flz Exp $
#
# PROVIDE: consolekit
# REQUIRE: DAEMON dbus
#
# Add the following line to /etc/rc.conf to enable the ConsoleKit daemon:
#
# consolekit_enable="YES"
#

. /etc/rc.subr
. /usr/local/etc/gnome.subr

consolekit_enable=${consolekit_enable-${gnome_enable}}

name=consolekit
rcvar=`set_rcvar`

command="/usr/local/sbin/console-kit-daemon"
pidfile="/var/run/${name}.pid"

start_precmd="consolekit_precmd"
stop_postcmd="consolekit_postcmd"

local_force_depend()
{
    _depend="$1"
    if [ -f /usr/local/etc/rc.d/${_depend}.sh ]; then
	_depend="${_depend}.sh"
    fi

    if ! /usr/local/etc/rc.d/${_depend} forcestatus 1>/dev/null 2>&1 &&
       ! /usr/local/etc/rc.d/${_depend} forcestart; then
       return 1
   fi
   return 0
}

consolekit_precmd()
{
    if ! checkyesno dbus_enable
    then
	local_force_depend dbus || return 1
    fi

    mkdir -p $(dirname $pidfile)
}

consolekit_postcmd()
{
    	rm -f $pidfile
}

load_rc_config ${name}
run_rc_command "$1"


syntax highlighted by Code2HTML, v. 0.9.1