## template:jinja
#!/bin/ksh

# PROVIDE: cloudconfig
# REQUIRE: cloudinit
# BEFORE: sshd


daemon="cloud-init"
daemon_execdir="{{prefix}}/bin"
daemon_flags="modules --mode config"
daemon_user=root

. /etc/rc.d/rc.subr

rc_usercheck="YES" # (undefined or "NO")

rc_start() {
    if test -e /etc/cloud/cloud-init.disabled; then
        echo -n "cloud-init is disabled via cloud-init.disabled file." | logger -t ${daemon}
    else
        echo -n "Starting..." | logger -t ${daemon}
        rc_exec "${daemon_execdir}/${daemon} ${daemon_flags}"
    fi
}

rc_check() {
    pgrep -f "${daemon}" >/dev/null
}

rc_stop() {
    echo -n "Stopping..." | logger -t ${daemon}
    pkill -f "${daemon}" >/dev/null
}

rc_cmd "$1"
