#!/usr/sbin/openrc-run

description="Miscellaneous things to be done during bootup."

depend()
{
	need mountnfs-bootclean.sh checkroot-bootclean.sh
	provide bootmisc
}

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

start()
{
	#
	# If login delaying is enabled then create the flag file
	# which prevents logins before startup is complete
	#
	case "$DELAYLOGIN" in
	  Y*|y*)
		echo "System bootup in progress - please wait" > /run/nologin
		;;
	esac

	# Remove bootclean's flag files.
	# Don't run bootclean again after this!
	rm -f /tmp/.clean /run/.clean /run/lock/.clean
	rm -f /tmp/.tmpfs /run/.tmpfs /run/lock/.tmpfs

	readonly utmp='/var/run/utmp'
	if > "${utmp}" ; then
		chgrp utmp "${utmp}" || ewarn "failed to chgrp ${utmp}"
		chmod 664  "${utmp}" || ewarn "failed to chmod ${utmp}"
		[ -x /sbin/restorecon ] && /sbin/restorecon "${utmp}"
		return 0
	else
		eerror "failed to truncate ${utmp}"
		return 1
	fi
	return $?
}

stop()
{
	return 0
}
