* [pmg-devel] [PATCH api] Use timedatectl for timezone handling
@ 2025-12-31 10:41 Stefan Mayr
0 siblings, 0 replies; only message in thread
From: Stefan Mayr @ 2025-12-31 10:41 UTC (permalink / raw)
To: pmg-devel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-12-31 10:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-31 10:41 [pmg-devel] [PATCH api] Use timedatectl for timezone handling Stefan Mayr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox