#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/rescue

# shellcheck source=runit/functions
. /usr/local/etc/runit/functions

detect_jail

if [ -z "${JAILED}" ] && [ -n "$(kenv boot_single 2>/dev/null)" ]; then
	if [ "x$(kenv boot_single)" = "xYES" ]; then
		echo "WARNING: Booting in single user mode!"
		emergency_shell
	fi
fi

# Start core services: one-time system tasks.
for f in /usr/local/etc/runit/core-services/*.sh; do
	# shellcheck disable=SC1090
	[ -r "$f" ] && . "$f"
done

if [ -z "${JAILED}" ]; then
	(
		umask 022
		/sbin/dmesg >/var/run/dmesg.boot
	)
fi
