#!/bin/sh

# PROVIDE: sssd
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable `sssd':
#
# sssd_enable="YES"
#
# See sssd(8) for sssd_flags
#

. /etc/rc.subr

name=sssd
rcvar=sssd_enable

# read configuration and set defaults
load_rc_config "$name"

: ${sssd_enable:=NO}
: ${sssd_conf="%%PREFIX%%/etc/sssd/sssd.conf"}
: ${sssd_flags="-f -D"}

command="%%PREFIX%%/sbin/$name"
pidfile="/var/run/$name.pid"
required_files="${sssd_conf}"
start_precmd=sssd_prestart

sssd_prestart()
{

	for i in db/sss/db db/sss/gpo_cache db/sss/keytabs db/sss/mc db/sss/pubconf/krb5.include.d/ db/sss/secrets log/sssd run/sss/pipes/private;  do
		if [ ! -d /var/${i} ]; then mkdir -p /var/${i}; fi
	done
}

run_rc_command "$1"
