#!/bin/sh
#
# Fixup kern.bootfile.  In a BOOT+ROOT setup the boot loader does not
# understand that the boot partition will be mounted as /boot under root
# in the actual system and sets up the kern.bootfile sysctl incorrectly.
# This fixes up kern.bootfile.
#

# PROVIDE: fixbootfile
# REQUIRE: FILESYSTEMS
# BEFORE:  sysctl

. /etc/rc.subr

name="fixbootfile"
start_cmd="fixbootfile_start"
stop_cmd=":"

fixbootfile_start()
{
	case ${fixbootfile} in
	[Nn][Oo])
		;;
	*)
		bootfile=`${SYSCTL_N} kern.bootfile`
		if [ -f "/boot$bootfile" ]; then
			${SYSCTL_W} kern.bootfile="/boot$bootfile"
		fi
		;;
	esac
}

load_rc_config $name
run_rc_command "$1"
