#!/bin/bash

# sourcing our current rc.conf requires this to be a bash script
. /usr/lib/rc/functions

start_bootlogd(){
    bootlogd -p /run/bootlogd.pid -l /var/log/boot.log || return 1
}

stop_bootlogd(){
    [[ -f /run/bootlogd.pid ]] || return 0
    touch /var/log/boot.log
    kill $(< /run/bootlogd.pid)
    rm -f /run/bootlogd.pid
}

case "$1" in
    start)
        stat_busy "Starting bootlogd"
        start_bootlogd || stat_die bootlogd
        add_daemon bootlogd
        stat_done bootlogd
        ;;
    stop)
        stat_busy "Stopping bootlogd"
        stop_bootlogd || stat_die bootlogd
        rm_daemon bootlogd
        stat_done bootlogd
        ;;
    *)
        echo "usage: $0 {start|stop}"
        exit 1
        ;;
esac
