#!/bin/bash # SPDX-Version: 3.0 # SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; # SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git # SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency # SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; # SPDX-FileType: SOURCE # SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0 # SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework. # SPDX-PackageName: CISS.debian.installer # SPDX-Security-Contact: security@coresecret.eu guard_sourcing ####################################### # Set locale, locale overrides and configure keyboard layout. # Globals: # TARGET # VAR_ARCHITECTURE # VAR_CODENAME # VAR_VERSION # locale_country # locale_keyboard_xkb_keymap # locale_language # locale_locale # locale_override_address # locale_override_collate # locale_override_ctype # locale_override_measurement # locale_override_messages # locale_override_monetary # locale_override_name # locale_override_numeric # locale_override_paper # locale_override_telephone # locale_override_time # Arguments: # None # Returns: # 0: on success ####################################### setup_locales() { ### Declare Arrays, HashMaps, and Variables. declare var_locale_hook="/root/.ciss/cdi/hooks/4050_setup_locales.hooks.sh" ### Give priority to '${locale_locale}' over separately configured variables '${locale_country}' and '${locale_language}'. ### If 'locale_locale' is not set, build it from 'locale_language' and 'locale_country'. if [[ -n "${locale_language:-}" && -n "${locale_country:-}" && -z "${locale_locale:-}" ]]; then declare locale_locale="${locale_language}_${locale_country}.UTF-8" fi ### Creat Hook in target. cat << EOF >| "${TARGET}${var_locale_hook}" #!/bin/bash # SPDX-Version: 3.0 # SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; # SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git # SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency # SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; # SPDX-FileType: SOURCE # SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0 # SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework. # SPDX-PackageName: CISS.debian.installer # SPDX-Security-Contact: security@coresecret.eu set -x set -Ceuo pipefail ### Register selections echo "locales locales/locales_to_be_generated multiselect ${locale_locale:-en_US.UTF-8} UTF-8" | debconf-set-selections echo "locales locales/default_environment_locale select ${locale_locale:-en_US.UTF-8}" | debconf-set-selections ### Reconfigure and regenerate dpkg-reconfigure -f noninteractive locales locale-gen if ! locale -a | grep -qx "${locale_locale:-en_US.UTF-8}"; then echo "ERROR: Locale '${locale_locale:-en_US.UTF-8}' has not been generated successfully." >&2 sleep 30 fi if update-locale \ LANG=${locale_locale} \ LC_ADDRESS=${locale_override_address:-${locale_locale}} \ LC_COLLATE=${locale_override_collate:-${locale_locale}} \ LC_CTYPE=${locale_override_ctype:-${locale_locale}} \ LC_MEASUREMENT=${locale_override_measurement:-${locale_locale}} \ LC_MESSAGES=${locale_override_messages:-${locale_locale}} \ LC_MONETARY=${locale_override_monetary:-${locale_locale}} \ LC_NAME=${locale_override_name:-${locale_locale}} \ LC_NUMERIC=${locale_override_numeric:-${locale_locale}} \ LC_PAPER=${locale_override_paper:-${locale_locale}} \ LC_TELEPHONE=${locale_override_telephone:-${locale_locale}} \ LC_TIME=${locale_override_time:-${locale_locale}} \ LC_IDENTIFICATION=${locale_locale} \ LC_ALL="" ;then echo "update-locale successful!" sleep 5 else echo "update-locale NOT successful!" sleep 60 fi # vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh EOF chmod 0700 "${TARGET}${var_locale_hook}" do_in_target_script "${TARGET}" "${var_locale_hook}" ### Set the keyboard layout for the system (for consoles). cat << EOF >| "${TARGET}/etc/default/keyboard" # SPDX-Version: 3.0 # SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; # SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git # SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency # SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; # SPDX-FileType: SOURCE # SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0 # SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework. # SPDX-PackageName: CISS.debian.installer # SPDX-Security-Contact: security@coresecret.eu # /etc/default/keyboard : Generated by CISS.debian.installer ${VAR_VERSION} # Architecture : ${VAR_ARCHITECTURE} # Distribution : ${VAR_CODENAME} # KEYBOARD CONFIGURATION FILE # Consult the keyboard(5) manual page. XKBMODEL="pc105" XKBLAYOUT="${locale_keyboard_xkb_keymap}" XKBVARIANT="" XKBOPTIONS="" BACKSPACE="guess" # vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=conf EOF chmod 0644 "${TARGET}/etc/default/keyboard" do_log "info" "file_only" "4050() Keyboard layout updated: 'XKBLAYOUT=${locale_keyboard_xkb_keymap}' -> '${TARGET}/etc/default/keyboard'." # TODO: Move this command later than 4131_installation_systemd.sh ### Set the X11 keyboard layout (for graphical environments). #do_in_target "${TARGET}" localectl set-x11-keymap "${locale_keyboard_xkb_keymap}" return 0 } # vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh