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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2023-04-03 12:54:08 +05:30 committed by James Valleroy
parent 459ac5ee3d
commit 48eadfdd51
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 10 additions and 2 deletions

View File

@ -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)

View File

@ -3,4 +3,9 @@
Application manifest for datetime.
"""
backup = {'data': {'files': ['/etc/timezone']}}
backup = {
'data': {
'files': ['/etc/localtime']
},
'services': ['systemd-timedated'],
}