mirror of
https://github.com/brain-hackers/brain-config.git
synced 2025-02-02 00:30:08 +09:00
Add non-interactive timezone, locale and keyboard configuration
This commit is contained in:
parent
5fd793fcbf
commit
35b44f1615
52
raspi-config
52
raspi-config
@ -290,20 +290,47 @@ do_change_pass() {
|
||||
}
|
||||
|
||||
do_configure_keyboard() {
|
||||
dpkg-reconfigure keyboard-configuration &&
|
||||
printf "Reloading keymap. This may take a short while\n" &&
|
||||
invoke-rc.d keyboard-setup start || return $?
|
||||
printf "Reloading keymap. This may take a short while\n"
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
dpkg-reconfigure keyboard-configuration
|
||||
else
|
||||
local KEYMAP="$1"
|
||||
sed -i /etc/default/keyboard -e "s/^XKBLAYOUT.*/XKBLAYOUT=\"$KEYMAP\"/"
|
||||
dpkg-reconfigure -f noninteractive keyboard-configuration
|
||||
fi
|
||||
invoke-rc.d keyboard-setup start
|
||||
setsid sh -c 'exec setupcon -k --force <> /dev/tty1 >&0 2>&1'
|
||||
udevadm trigger --subsystem-match=input --action=change
|
||||
return 0
|
||||
}
|
||||
|
||||
do_change_locale() {
|
||||
dpkg-reconfigure locales
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
dpkg-reconfigure locales
|
||||
else
|
||||
local LOCALE="$1"
|
||||
if ! LOCALE_LINE="$(grep "^$LOCALE " /usr/share/i18n/SUPPORTED)"; then
|
||||
return 1
|
||||
fi
|
||||
local ENCODING="$(echo $LOCALE_LINE | cut -f2 -d " ")"
|
||||
echo "$LOCALE $ENCODING" > /etc/locale.gen
|
||||
sed -i "s/^\s*LANG=\S*/LANG=$LOCALE/" /etc/default/locale
|
||||
dpkg-reconfigure -f noninteractive locales
|
||||
fi
|
||||
}
|
||||
|
||||
do_change_timezone() {
|
||||
dpkg-reconfigure tzdata
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
dpkg-reconfigure tzdata
|
||||
else
|
||||
local TIMEZONE="$1"
|
||||
if [ ! -f "/usr/share/zoneinfo/$TIMEZONE" ]; then
|
||||
return 1;
|
||||
fi
|
||||
rm /etc/localtime
|
||||
echo "$TIMEZONE" > /etc/timezone
|
||||
dpkg-reconfigure -f noninteractive tzdata
|
||||
fi
|
||||
}
|
||||
|
||||
get_wifi_country() {
|
||||
@ -1469,23 +1496,12 @@ do_apply_os_config() {
|
||||
|
||||
if [ -n "$DEBLANGUAGE" ]; then
|
||||
printf "Setting language to %s based on os_config.json from NOOBS. May take a while\n" "$DEBLANGUAGE"
|
||||
cat << EOF | debconf-set-selections
|
||||
locales locales/locales_to_be_generated multiselect $DEBLANGUAGE UTF-8
|
||||
EOF
|
||||
rm /etc/locale.gen
|
||||
dpkg-reconfigure -f noninteractive locales
|
||||
update-locale LANG="$DEBLANGUAGE"
|
||||
cat << EOF | debconf-set-selections
|
||||
locales locales/default_environment_locale select $DEBLANGUAGE
|
||||
EOF
|
||||
do_change_locale "$DEBLANGUAGE"
|
||||
fi
|
||||
|
||||
if [ -n "$NOOBSKEYBOARD" -a "$NOOBSKEYBOARD" != "gb" ]; then
|
||||
printf "Setting keyboard layout to %s based on os_config.json from NOOBS. May take a while\n" "$NOOBSKEYBOARD"
|
||||
sed -i /etc/default/keyboard -e "s/^XKBLAYOUT.*/XKBLAYOUT=\"$NOOBSKEYBOARD\"/"
|
||||
dpkg-reconfigure -f noninteractive keyboard-configuration
|
||||
setupcon -k --force
|
||||
udevadm trigger -p ID_INPUT_KEY=1
|
||||
do_configure_keyboard "$NOOBSKEYBOARD"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user