1
0
mirror of https://github.com/home-assistant/operating-system.git synced 2026-02-15 07:29:08 +00:00
Files
operating-system/buildroot-external/scripts/post-build.sh
Jan Čermák 7243db762e Make system timezone setting persistenly configurable (#4224)
To make system timezone configurable, we need to have /etc/localtime
writable, and it must be possible to atomically create a symlink from
this place, which means the whole parent folder must be writable. We
don't have /etc writable and can't use the usual bind mount for this.

Latest Systemd v258 has patch that allows setting an environment
variable that sets where the localtime should be written. This can be
persisted in the overlay partition, with a symlink from /etc/localtime
leading there, finally pointing to the actual zoneinfo file. If the
symlink doesn't exist, create it by hassos-overlay script (it's not
really needed as UTC is the default, but Systemd does the same if you
change from non-UTC timezone back to UTC).

Also disable BR2_TARGET_LOCALTIME, so /etc/localtime and /etc/timezone
(the latter is only informative and non-standard) are not written by the
tzdata package build.
2025-08-13 18:15:57 +02:00

52 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# shellcheck disable=SC1090,SC1091
set -e
SCRIPT_DIR=${BR2_EXTERNAL_HASSOS_PATH}/scripts
BOARD_DIR=${2}
. "${BR2_EXTERNAL_HASSOS_PATH}/meta"
. "${BOARD_DIR}/meta"
. "${SCRIPT_DIR}/rootfs-layer.sh"
. "${SCRIPT_DIR}/name.sh"
. "${SCRIPT_DIR}/rauc.sh"
# HassOS tasks
fix_rootfs
install_tini_docker
setup_localtime
# Write os-release
# shellcheck disable=SC2153
(
echo "NAME=\"${HASSOS_NAME}\""
echo "VERSION=\"$(hassos_version) (${BOARD_NAME})\""
echo "ID=${HASSOS_ID}"
echo "VERSION_ID=$(hassos_version)"
echo "PRETTY_NAME=\"${HASSOS_NAME} $(hassos_version)\""
echo "CPE_NAME=cpe:2.3:o:home-assistant:${HASSOS_ID}:$(hassos_version):*:${DEPLOYMENT}:*:*:*:${BOARD_ID}:*"
echo "HOME_URL=https://hass.io/"
echo "VARIANT=\"${HASSOS_NAME} ${BOARD_NAME}\""
echo "VARIANT_ID=${BOARD_ID}"
echo "SUPERVISOR_MACHINE=${SUPERVISOR_MACHINE}"
echo "SUPERVISOR_ARCH=${SUPERVISOR_ARCH}"
) > "${TARGET_DIR}/usr/lib/os-release"
# Write machine-info
(
echo "CHASSIS=${CHASSIS}"
echo "DEPLOYMENT=${DEPLOYMENT}"
) > "${TARGET_DIR}/etc/machine-info"
# Setup RAUC
prepare_rauc_signing
write_rauc_config
install_rauc_certs
install_bootloader_config
# Fix overlay presets
"${HOST_DIR}/bin/systemctl" --root="${TARGET_DIR}" preset-all