#!/bin/sh
#
#
# chkconfig: 5 04 05
# description: This startup script sets locale from /proc/cmdline

WITHOUT_RC_COMPAT=1


# Source function library.
. /etc/init.d/functions

RETVAL=0

start()
{
	echo "setting locale"
	in_locale=`grep -o 'lang=[^ ]*' /proc/cmdline`
	if [ $in_locale ] ; then
		in_locale=`echo $in_locale | cut -d = -f 2`
		echo $in_locale
		subst "s/ru_RU/$in_locale/g" /etc/sysconfig/i18n
	kbmap=`alterator-cmdline /syskbd action list language $in_locale | grep -o -m 1  'name "[a-z_]*"' | head -n 1 | sed -e 's/.*"\([a-z_]*\)"/\1/'`
	alterator-cmdline /syskbd action write language $in_locale _objects $kbmap
	fi
}

stop()
{
	true
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	*)
		msg_usage "${0##*/} {start|stop}"
		RETVAL=1
esac

exit $RETVAL
