#!/bin/sh
#
# $FreeBSD: ports/sysutils/policykit/files/polkitd.in,v 1.2 2006/10/31 09:40:42 jylefort Exp $
#
# PROVIDE: polkitd
# REQUIRE: DAEMON dbus
#
# Add the following line to /etc/rc.conf to enable the PolicyKit daemon:
#
# polkitd_enable="YES"
#

. %%RC_SUBR%%
. %%GNOME_SUBR%%

polkitd_enable=${polkitd_enable-${gnome_enable}}

name=polkitd
rcvar=`set_rcvar`

command="%%PREFIX%%/sbin/polkitd"
pidfile="/var/run/${name}/${name}.pid"

start_precmd="polkitd_precmd"
stop_postcmd="polkitd_postcmd"

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

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

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

    mkdir -p $(dirname $pidfile)
}

polkitd_postcmd()
{
    	rm -f $pidfile
}

load_rc_config ${name}
run_rc_command "$1"


syntax highlighted by Code2HTML, v. 0.9.1