From 742e2ce52e28412205243f97b79f47850d87efe0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 07:12:45 +0000 Subject: [PATCH] Add container timezone management for birdnet-pipy addon - New init script 02-timezone.sh: reads TZ from addon config, validates against /usr/share/zoneinfo, applies to container (/etc/localtime, /etc/timezone, s6 container env) - Change default TZ from Etc/UTC to Europe/Paris - Increment version to 0.5.6-2 - Update CHANGELOG.md and DOCS.md Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com> --- birdnet-pipy/CHANGELOG.md | 4 +++ birdnet-pipy/DOCS.md | 2 +- birdnet-pipy/config.yaml | 4 +-- .../rootfs/etc/cont-init.d/02-timezone.sh | 26 +++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 birdnet-pipy/rootfs/etc/cont-init.d/02-timezone.sh diff --git a/birdnet-pipy/CHANGELOG.md b/birdnet-pipy/CHANGELOG.md index a96e52b30..409fd39ac 100644 --- a/birdnet-pipy/CHANGELOG.md +++ b/birdnet-pipy/CHANGELOG.md @@ -1,4 +1,8 @@ +## 0.5.6-2 (2026-03-11) +- Add container timezone management: TZ option now properly configures the container timezone (symlinks /etc/localtime, writes /etc/timezone, exports to s6 environment) +- Change default timezone from Etc/UTC to Europe/Paris + ## 0.5.6 (2026-03-07) - Update to latest version from Suncuss/BirdNET-PiPy (changelog : https://github.com/Suncuss/BirdNET-PiPy/releases) ## 0.5.5-2 (04-03-2026) diff --git a/birdnet-pipy/DOCS.md b/birdnet-pipy/DOCS.md index 59b2e3492..2d5f297b1 100644 --- a/birdnet-pipy/DOCS.md +++ b/birdnet-pipy/DOCS.md @@ -15,7 +15,7 @@ ## Options ```yaml -TZ: Etc/UTC # Timezone, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List +TZ: Europe/Paris # Timezone, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List ICECAST_PASSWORD: "" # Optional: set a persistent password for the audio stream STREAM_BITRATE: 320k # Bitrate for the mp3 stream RECORDING_MODE: rtsp # pulseaudio | http_stream | rtsp diff --git a/birdnet-pipy/config.yaml b/birdnet-pipy/config.yaml index 7fa217743..c00cb3d69 100644 --- a/birdnet-pipy/config.yaml +++ b/birdnet-pipy/config.yaml @@ -73,7 +73,7 @@ name: BirdNET-PiPy options: env_vars: [] ICECAST_PASSWORD: '' - TZ: Etc/UTC + TZ: Europe/Paris data_location: /config/data panel_icon: mdi:bird ports: @@ -97,5 +97,5 @@ schema: ssl: bool? slug: birdnet-pipy url: https://github.com/alexbelgium/hassio-addons/tree/master/birdnet-pipy -version: "0.5.6" +version: "0.5.6-2" webui: "[PROTO:ssl]://[HOST]:[PORT:80]" diff --git a/birdnet-pipy/rootfs/etc/cont-init.d/02-timezone.sh b/birdnet-pipy/rootfs/etc/cont-init.d/02-timezone.sh new file mode 100644 index 000000000..7b0b958e4 --- /dev/null +++ b/birdnet-pipy/rootfs/etc/cont-init.d/02-timezone.sh @@ -0,0 +1,26 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +set -euo pipefail + +# Use timezone defined in add-on options +bashio::log.info "Setting timezone..." +TZ_VALUE="$(bashio::config 'TZ' || true)" +TZ_VALUE="${TZ_VALUE:-Europe/Paris}" + +if [ ! -f "/usr/share/zoneinfo/${TZ_VALUE}" ]; then + bashio::log.warning "Invalid timezone '${TZ_VALUE}'. Falling back to Europe/Paris." + bashio::log.warning "See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for valid values." + TZ_VALUE="Europe/Paris" +fi + +# Apply timezone to the container +ln -sf "/usr/share/zoneinfo/${TZ_VALUE}" /etc/localtime +echo "${TZ_VALUE}" > /etc/timezone +export TZ="${TZ_VALUE}" + +# Update s6 container environment so child processes inherit the timezone +if [ -d /var/run/s6/container_environment ]; then + echo "${TZ_VALUE}" > /var/run/s6/container_environment/TZ +fi + +bashio::log.notice "Timezone set to: ${TZ_VALUE}"