2009-03-06 04:17:46 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# PROVIDE: locale
|
|
|
|
# REQUIRE: cleartmp
|
|
|
|
# BEFORE: NETWORKING
|
|
|
|
|
|
|
|
$_rc_subr_loaded . /etc/rc.subr
|
|
|
|
|
|
|
|
name="locale"
|
|
|
|
start_cmd="locale_start"
|
|
|
|
stop_cmd=":"
|
|
|
|
|
|
|
|
locale_start()
|
|
|
|
{
|
|
|
|
# Flush old locale settings
|
|
|
|
[ ! -d /etc/profile.d ] && mkdir -p /etc/profile.d
|
|
|
|
|
|
|
|
: >/etc/profile.d/locale.sh
|
|
|
|
chmod 755 /etc/profile.d/locale.sh
|
|
|
|
|
|
|
|
# Check if requested locale was already created
|
2009-03-26 09:07:50 +00:00
|
|
|
if ! $(locale -a|grep -q $LOCALE.utf8); then
|
2009-03-06 04:17:46 +00:00
|
|
|
[ ! -d /usr/lib/locale ] && mkdir -p /usr/lib/locale
|
2009-03-26 09:07:50 +00:00
|
|
|
echo -n "Building locale: $LOCALE... "
|
|
|
|
localedef -i ${LOCALE} -f UTF-8 ${LOCALE}
|
2009-03-06 04:17:46 +00:00
|
|
|
show_rval
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set user defined locale
|
|
|
|
[ -z "$LOCALE" ] && LOCALE="en_US"
|
2009-03-26 09:07:50 +00:00
|
|
|
echo -n "Setting locale: $LOCALE... "
|
2009-03-06 04:17:46 +00:00
|
|
|
echo "export LANG=$LOCALE" >> /etc/profile.d/locale.sh
|
|
|
|
show_rval
|
|
|
|
|
|
|
|
if echo "$LOCALE" | grep -qi utf ; then
|
|
|
|
if [ -n "$KEYMAP" ]; then
|
2009-03-26 09:07:50 +00:00
|
|
|
echo -n "Loading keyboard map: $KEYMAP... "
|
2009-03-06 04:17:46 +00:00
|
|
|
loadkeys -q -u $KEYMAP
|
|
|
|
show_rval
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -n "$KEYMAP" ]; then
|
2009-03-26 09:07:50 +00:00
|
|
|
echo -n "Loading keyboard map: $KEYMAP... "
|
2009-03-06 04:17:46 +00:00
|
|
|
loadkeys -q $KEYMAP
|
|
|
|
show_rval
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$CONSOLEFONT" ]; then
|
2009-03-26 09:07:50 +00:00
|
|
|
echo -n "Loading console font: $CONSOLEFONT... "
|
2009-03-06 04:17:46 +00:00
|
|
|
# CONSOLEMAP in UTF-8 shouldn't be used
|
|
|
|
if [ -n "$CONSOLEMAP" ] && echo "$LOCALE" | grep -qi utf ; then
|
|
|
|
CONSOLEMAP=""
|
|
|
|
fi
|
|
|
|
for i in $(seq 0 63); do
|
|
|
|
[ ! -e /dev/tty${i} ] && continue
|
|
|
|
if [ -n "$CONSOLEMAP" ]; then
|
|
|
|
setfont -m $CONSOLEMAP $CONSOLEFONT -C \
|
|
|
|
/dev/tty${i} >/dev/null 2>&1
|
|
|
|
else
|
|
|
|
setfont $CONSOLEFONT -C /dev/tty${i} \
|
|
|
|
>/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
done
|
2009-03-06 05:30:38 +00:00
|
|
|
show_rval
|
2009-03-06 04:17:46 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|