Skip to content

majestic: export TZ in S95majestic so the OSD clock is local - #2244

Open
phedoreanu wants to merge 1 commit into
OpenIPC:masterfrom
phedoreanu:s95majestic-tz
Open

majestic: export TZ in S95majestic so the OSD clock is local#2244
phedoreanu wants to merge 1 commit into
OpenIPC:masterfrom
phedoreanu:s95majestic-tz

Conversation

@phedoreanu

Copy link
Copy Markdown

majestic is launched by init, which never sources /etc/profile, so the TZ=$(cat /etc/TZ) export in there does not reach it — the OSD clock burns in UTC even when /etc/TZ is set correctly. musl does not read /etc/TZ by itself; the environment variable is the only channel.

This exports TZ in the init script before starting the daemon.

Verified on a Hi3518EV200 camera with TZ='CET-1CEST,M3.5.0,M10.5.0/3': the OSD clock follows local time including DST, and tr '\0' '\n' < /proc/$(pidof majestic)/environ | grep ^TZ= confirms the variable is set in the running process.

majestic is launched by init, which never sources /etc/profile, so the
TZ=$(cat /etc/TZ) export in there does not reach it and the OSD clock
burns in UTC even when /etc/TZ is set correctly. musl does not read
/etc/TZ by itself - the environment variable is the only channel.

Export TZ in the init script before starting the daemon. Verified on a
Hi3518EV200 camera with TZ 'CET-1CEST,M3.5.0,M10.5.0/3': the OSD clock
follows local time including DST, and
tr '\0' '\n' < /proc/$(pidof majestic)/environ shows TZ set.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

majestic: export TZ in S95majestic so OSD clock uses local time

🐞 Bug fix ⚙️ Configuration changes 🕐 Less than 10 minutes

Grey Divider

AI Description

• Export TZ from /etc/TZ before launching majestic via init.
• Fix OSD clock rendering UTC when /etc/profile is not sourced.
• Document musl timezone behavior and why the export is required.
Diagram

graph TD
  A["init"] --> B["S95majestic"] --> C{"
/etc/TZ readable?
"}
  C -- "yes" --> D["export TZ"] --> E["start majestic"] --> F["OSD clock"]
  C -- "no" --> E

  subgraph Legend
    direction LR
    _proc["Process"] ~~~ _cfg["Config file"] ~~~ _dec{"Decision"}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Set TZ globally in init environment
  • ➕ Ensures all init-started daemons inherit TZ consistently
  • ➕ Avoids per-service duplicated logic
  • ➖ Depends on init system capabilities and conventions
  • ➖ Broader blast radius if TZ parsing/config is wrong
2. Make majestic read /etc/TZ (or /etc/localtime) internally
  • ➕ Removes reliance on init/exported environment
  • ➕ Keeps timezone behavior self-contained within the daemon
  • ➖ Requires changing application code (larger review and testing surface)
  • ➖ Still must reconcile musl/embedded timezone data availability

Recommendation: Exporting TZ in S95majestic is the smallest, most targeted fix given init does not source /etc/profile and musl won’t consult /etc/TZ automatically. Consider a global init-level TZ export only if multiple services show the same issue; otherwise the per-daemon init-script export is appropriate.

Files changed (1) +5 / -0

Bug fix (1) +5 / -0
S95majesticExport TZ from /etc/TZ before launching majestic +5/-0

Export TZ from /etc/TZ before launching majestic

• Adds a guarded read of /etc/TZ and exports TZ so the init-launched majestic process inherits the correct timezone. Includes comments explaining why /etc/profile is insufficient and why musl requires the environment variable.

general/package/majestic/files/S95majestic

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can ask Qodo to dismiss a finding you disagree with, with your reason on record

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant