export LANG=C

if [ "$TERM" = vt102 -a `tty` = /dev/tty1 ] ; then
	# Busybox's init uses a global TERM across all consoles.
	# If the serial console is the default such as on arm64, that
	# will force vt102 on the Linux VT. Fix this back so we get
	# colors, utf-8, etc.
	TERM=linux
fi

if [ "$TERM" = linux ] ; then
	if [ "$TERM_TYPE" = virtual ]; then
		echo -ne "\033[9;0]" # Turn off console blanking.
	fi

	# Enable UTF-8 locale if it is available
	if [ -d /usr/lib/locale/C.UTF-8 ]; then
		TERM_UTF8=yes
		: >/var/lib/UTF-8
		export LANG=C.UTF-8
		if [ "$TERM_TYPE" = virtual ]; then
			echo -ne "\033%G" # Enable UTF-8 console
		fi
	fi
fi
