From: Stefan Mayr <stefan@mayr-stefan.de>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH api] Use timedatectl for timezone handling
Date: Wed, 31 Dec 2025 11:41:06 +0100 [thread overview]
Message-ID: <20251231104105.6788-1-stefan@mayr-stefan.de> (raw)
Usage of /etc/timezone is deprecated. The tzdata maintainers recommend
switching to timedatectl.
Almost the same patch was sent to pve-devel to fix #7175. Transfering
this change to PMG should allow us to remove handling /etc/timezone in
the INotify module from
pve-common.
I hope we got all perl dependencies. From a quick peek someone has to do
the same for the rust code parts.
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Suggested-by: Maximiliano Sandroval <m.sandoval@proxmox.com>
Signed-off-by: Stefan Mayr <stefan@mayr-stefan.de>
---
src/PMG/API2/Nodes.pm | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/PMG/API2/Nodes.pm b/src/PMG/API2/Nodes.pm
index 3479d64..d95657b 100644
--- a/src/PMG/API2/Nodes.pm
+++ b/src/PMG/API2/Nodes.pm
@@ -659,10 +659,15 @@ __PACKAGE__->register_method({
code => sub {
my ($param) = @_;
+ my $timezone;
my $ctime = time();
my $ltime = timegm_nocheck(localtime($ctime));
+ PVE::Tools::run_command(
+ ['timedatectl', 'show', '--property=Timezone', '--value'],
+ outfunc => sub { $timezone //= shift },
+ );
my $res = {
- timezone => PVE::INotify::read_file('timezone'),
+ timezone => $timezone,
time => time(),
localtime => $ltime,
};
@@ -693,7 +698,7 @@ __PACKAGE__->register_method({
code => sub {
my ($param) = @_;
- PVE::INotify::write_file('timezone', $param->{timezone});
+ PVE::Tools::run_command(['timedatectl', 'set-timezone', $param->{timezone}]);
return undef;
},
--
2.34.1
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
reply other threads:[~2025-12-31 10:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251231104105.6788-1-stefan@mayr-stefan.de \
--to=stefan@mayr-stefan.de \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox