#!/bin/sh

# Copyright (c) 2018-2022, diyIT.org
# All rights reserved.
#
# BSD 2-Clause License ("Simplified BSD License" or "FreeBSD License")
# https://diyit.org/license/
#
#

# the two lines below are not just comments but required by rcorder; service -e
# PROVIDE: acmedns
# REQUIRE: NETWORKING DAEMON

. /etc/rc.subr

: ${acmedns_enable="NO"}

name=acmedns
rcvar=${name}_enable

ACMEDNS="/usr/local/bin/acme-dns"

start_cmd="${name}_start"
stop_cmd="${name}_stop"
restart_cmd="${name}_restart"

acmedns_start()
{
        $ACMEDNS -c /etc/acme-dns/config.cfg &
}

acmedns_stop()
{
        ps ax | grep -ie acme-dns | grep -v grep | awk '{print $1}' | xargs kill -9
}
acmedns_restart()
{
	acmedns_stop
	acmedns_start
}

load_rc_config ${name}
run_rc_command "$1"
