#!/usr/sbin/openrc-run

description="Log file handling during bootup."

depend()
{
	need hostname.sh mountall.sh
	provide bootlogs
}

[ "$DELAYLOGIN" ] || DELAYLOGIN=yes
. /lib/init/vars.sh

start()
{
	if test -f /var/log/dmesg; then
		savelog -q -p -c 5 /var/log/dmesg
	else
		touch /var/log/dmesg
		chown root:adm /var/log/dmesg
		chmod 640 /var/log/dmesg
	fi

	if command -v dmesg >/dev/null 2>&1; then
		dmesg -s 524288 > /var/log/dmesg
	elif [ -c /dev/klog ]; then
		dd if=/dev/klog of=/var/log/dmesg &
		sleep 1
		kill $! 2>/dev/null || true
	fi
	return 0
}

stop()
{
	return 0
}
