#!/bin/sh
#
#	$Id: setsysfont 7036 2006-02-27 18:09:56Z glen $
#

[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
[ -f /etc/sysconfig/console ] && . /etc/sysconfig/console

[ -n "$SYSFONT" ] && CONSOLEFONT="$SYSFONT"

case "$LANG" in
  *.utf8|*.UTF-8)
	if [ -x /bin/unicode_start ] && /sbin/consoletype fg ; then
		exec unicode_start $CONSOLEFONT $CONSOLEMAP
	fi
	;;
esac

# console-tools, obsolete part
if [ -x /usr/bin/consolechars -o -x /bin/consolechars ]; then
	if [ -n "$CONSOLEFONT" ]; then
		consolechars --acm ${CONSOLEMAP:-trivial.trans} --font $CONSOLEFONT
	fi
	if [ -n "$KEYTABLE" ]; then
		loadkeys $KEYTABLE < /dev/tty0 > /dev/tty0
	fi
# kbd, currently used
elif [ -x /usr/bin/setfont -o -x /bin/setfont ]; then
	if [ -n "$CONSOLESCREENFONTMAP" ]; then
		ARGS="-u $CONSOLESCREENFONTMAP"
	fi
	if [ -n "$CONSOLEMAP" ]; then
		if [ ! -f /lib/kbd/consoletrans/${CONSOLEMAP}_to_uni.trans ]; then
			CONSOLEMAP=$(echo "$CONSOLEMAP" | sed "s|iso0|8859-|g;s|iso|8859-|g")
		fi
		ARGS="$ARGS -m $CONSOLEMAP"
	fi
	if [ -n "$CONSOLEFONT" ]; then
		setfont $CONSOLEFONT $ARGS
	else
		echo -ne "\033(K" 2>/dev/null > /proc/$$/fd/0
	fi
fi

exit 0

# This must be last line !
# vi:syntax=sh
