#!/bin/sh
#
# $NetBSD: openarc.sh,v 1.1 2025/12/11 00:48:28 manu Exp $
#
# PROVIDE: openarc
# REQUIRE: DAEMON
# BEFORE: mail

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
fi

name="openarc"
rcvar=$name
command="/usr/pkg/sbin/openarc"
pidfile="/var/run/openarc/${name}.pid"
command_args="-P ${pidfile} -c /usr/pkg/etc/openarc.conf" 
required_files="/usr/pkg/etc/openarc.conf"
start_precmd="openarc_precmd"

openarc_precmd()
{
        if [ ! -d /var/run/openarc ]; then
                /bin/mkdir -p /var/run/openarc
                /bin/chmod 0750 /var/run/openarc
        fi

	if [ -f /var/run/openarc/${name}.sock ]; then
		/bin/rm -f /var/run/openarc/${name}.sock
	fi
}

if [ -f /etc/rc.subr ]; then
        load_rc_config $name
	run_rc_command "$1"
else
	echo -n " ${name}"
	${command} ${openarc_flags} ${command_args}
fi
