#!/bin/sh

set -e

# create /dev/nvram if it doesn't exist yet
if [ ! -c /dev/nvram ]; then
	# policy requires to ask before creating the device
	echo "Your system lacks the /dev/nvram device."
	echo -n "Should it be created now? [Y/n] "
	read yn
	case "$yn" in
		[nN]*)
			echo "You can call /dev/MAKEDEV nvram later to create /dev/nvram"
			echo "Without this device, nvram can't work properly"
			;;
		*)
			/dev/MAKEDEV nvram
			# MAKEDEV returns 0 even if it can create the device...
			if [ ! -c /dev/nvram ]; then
				echo "MAKEDEV failed to create /dev/nvram"
				exit 1
			fi
			;;
	esac
fi

# warn if current kernel doesn't have /dev/nvram support
if [ ! -e /proc/nvram ]; then
	echo "Warning: The currently running kernel doesn't have support for /dev/nvram!"
fi

#DEBHELPER#

exit 0
