Skip to content

Commit df4ba9b

Browse files
fix(init): pass timezone via env var instead of reading missing file
init-root.sh was reading timezone from /etc/box-assembled.ini, but that file is only copied into the container after init hooks complete. Pass BOX_TIMEZONE as an env var through pre_init_hooks so it's available when init-root.sh runs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 469a0c9 commit df4ba9b

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

scripts/compile-box-toml.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ def compile_toml(box_dir: pathlib.Path) -> str:
4242
timezone = distrobox.pop("timezone", "")
4343
additional_flags = distrobox.pop("additional_flags", "")
4444

45+
# Inject timezone into pre_init_hooks so init-root.sh can read it
46+
# (init_hooks run before box-assembled.ini is copied into the container)
47+
if timezone:
48+
pre = distrobox.get("pre_init_hooks", "")
49+
export = f"export BOX_TIMEZONE={timezone}"
50+
distrobox["pre_init_hooks"] = f"{pre} && {export}" if pre else export
51+
4552
# Append mount-file entries to additional_flags as --volume
4653
for mf in mount_files:
4754
vol = f"{mf['host']}:{mf['container']}"

scripts/init-root.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ readonly user="${1:?Usage: init-root.sh <username>}"
88

99
printf '[box-init] root init start\n'
1010

11-
# Set timezone from box.toml (compiled into box-assembled.ini as box-meta comment)
12-
tz="$(grep -oP '^# box-meta:timezone=\K.+' /etc/box-assembled.ini 2>/dev/null || true)"
11+
# Set timezone — BOX_TIMEZONE is injected via pre_init_hooks by the compiler
12+
tz="${BOX_TIMEZONE:-}"
1313
if [[ -n "$tz" ]]; then
1414
if [[ -f "/usr/share/zoneinfo/$tz" ]]; then
1515
umount /etc/localtime 2>/dev/null || true

0 commit comments

Comments
 (0)