Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/ns-api/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2022 Nethesis S.r.l.
# Copyright (C) 2026 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-2.0-only
#

Expand Down Expand Up @@ -179,6 +179,7 @@ define Package/ns-api/install
$(INSTALL_BIN) ./files/pre-commit/update-objects.py $(1)/usr/libexec/ns-api/pre-commit
$(INSTALL_BIN) ./files/post-commit/reload-ipsets.py $(1)/usr/libexec/ns-api/post-commit
$(INSTALL_BIN) ./files/post-commit/restart-cron.py $(1)/usr/libexec/ns-api/post-commit
$(INSTALL_BIN) ./files/post-commit/update-timezone.py $(1)/usr/libexec/ns-api/post-commit
$(INSTALL_BIN) ./files/post-commit/restart-wireguard.py $(1)/usr/libexec/ns-api/post-commit
$(INSTALL_BIN) ./files/pre-commit/clean-network.py $(1)/usr/libexec/ns-api/pre-commit
$(INSTALL_BIN) ./files/remove-pppoe-keepalive $(1)/usr/share/ns-api
Expand Down
30 changes: 30 additions & 0 deletions packages/ns-api/files/post-commit/update-timezone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/python3

#
# Copyright (C) 2026 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-2.0-only
#

import subprocess

if 'system' in changes:
system_changes = changes['system']
timezone_value = None
zonename_value = None

# extract timezone and zonename values from changes
for change in system_changes:
if len(change) >= 4:
if change[2] == 'timezone':
timezone_value = change[3]
elif change[2] == 'zonename':
zonename_value = change[3]

# update symlink and TZ variable if changed
if zonename_value:
# replace spaces with underscores like /etc/init.d/system does
zonename_normalized = zonename_value.replace(' ', '_')
subprocess.run(["/bin/ln", "-sf", f"/usr/share/zoneinfo/{zonename_normalized}", "/etc/localtime"], check=True, capture_output=True)

if timezone_value:
subprocess.run(["/bin/sh", "-c", f"echo '{timezone_value}' > /tmp/TZ"], check=True, capture_output=True)
Loading