From 48eadfdd514d4b07073c64e0f49c2be840090e4d Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 3 Apr 2023 12:54:08 +0530 Subject: [PATCH] datetime: Re-implment backup/restore for timezone Closes: #2326. Earlier /etc/timezone was used to store timezone. Now, we use /etc/localtime symlink instead. Since the change, backup/restore for timezone has not been working. Implement this by backing up and restoring the new symlink. Borg understands symlinks so it properly backs them up and restore them. When the symlink is restored, timedatectl does not immediately show the new timezone. This is because a DBus activated daemon 'systemd-timedated' which supplies the information for timedatectl needs to be reloaded. Add this service to list of services that backup framework needs to restart. Tests: - Set a new timezone. Backup datetime app. Set another timezone. Restore the datetime app. Visiting the datetime app shows the restored timezone as expected and timedatectl on command line also immediately shows the expected timezone. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/datetime/__init__.py | 5 ++++- plinth/modules/datetime/manifest.py | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plinth/modules/datetime/__init__.py b/plinth/modules/datetime/__init__.py index e51cd50cd..229e47fae 100644 --- a/plinth/modules/datetime/__init__.py +++ b/plinth/modules/datetime/__init__.py @@ -9,7 +9,7 @@ from django.utils.translation import gettext_lazy as _ from plinth import app as app_module from plinth import menu -from plinth.daemon import Daemon +from plinth.daemon import Daemon, RelatedDaemon from plinth.modules.backups.components import BackupRestore from plinth.package import Packages @@ -75,6 +75,9 @@ class DateTimeApp(app_module.App): packages = Packages('packages-datetime', ['systemd-timesyncd']) self.add(packages) + daemon = RelatedDaemon('daemon-datetime', 'systemd-timedated') + self.add(daemon) + if self._is_time_managed(): daemon = Daemon('daemon-datetime', 'systemd-timesyncd') self.add(daemon) diff --git a/plinth/modules/datetime/manifest.py b/plinth/modules/datetime/manifest.py index 59f2d45f9..229b34d40 100644 --- a/plinth/modules/datetime/manifest.py +++ b/plinth/modules/datetime/manifest.py @@ -3,4 +3,9 @@ Application manifest for datetime. """ -backup = {'data': {'files': ['/etc/timezone']}} +backup = { + 'data': { + 'files': ['/etc/localtime'] + }, + 'services': ['systemd-timedated'], +}