void-packages/templates/initscripts/files/rc.d/locale
Juan RP a3190ec48c initscripts: misc changes, bump to 2009-03.
--HG--
extra : convert_revision : 97fb9127cb91659331f1574a19a8871fed30a0ab
2009-03-26 10:07:50 +01:00

70 lines
1.5 KiB
Bash
Executable file

#!/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
if ! $(locale -a|grep -q $LOCALE.utf8); then
[ ! -d /usr/lib/locale ] && mkdir -p /usr/lib/locale
echo -n "Building locale: $LOCALE... "
localedef -i ${LOCALE} -f UTF-8 ${LOCALE}
show_rval
fi
# Set user defined locale
[ -z "$LOCALE" ] && LOCALE="en_US"
echo -n "Setting locale: $LOCALE... "
echo "export LANG=$LOCALE" >> /etc/profile.d/locale.sh
show_rval
if echo "$LOCALE" | grep -qi utf ; then
if [ -n "$KEYMAP" ]; then
echo -n "Loading keyboard map: $KEYMAP... "
loadkeys -q -u $KEYMAP
show_rval
fi
else
if [ -n "$KEYMAP" ]; then
echo -n "Loading keyboard map: $KEYMAP... "
loadkeys -q $KEYMAP
show_rval
fi
fi
if [ -n "$CONSOLEFONT" ]; then
echo -n "Loading console font: $CONSOLEFONT... "
# 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
show_rval
fi
}
load_rc_config $name
run_rc_command "$1"