#!/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()
{
	in_locale=`grep -o 'lang=[^ ]*' /proc/cmdline`
	if [ $in_locale ] ; then
		in_locale=`echo $in_locale | cut -d = -f 2`
		echo "setting locale to $in_locale"
		kbmap=`alterator-cmdline /sysconfig-base/kbd action list language $in_locale -k name | head -n 1`
		alterator-cmdline /sysconfig-base/kbd action write language "$in_locale" layout "$kbmap"
		alterator-cmdline /sysconfig-base/language action write lang "$in_locale"
	fi
}

# See how we were called.
case "$1" in
	start)
		start
		;;
    stop|condstop|status)
        ;;
    restart|reload|condrestart|condreload)
        ;;
    *)
        msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
        RETVAL=1

esac

exit $RETVAL
