mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
datetime: Switch from chrony to systemd-timesyncd
Previously, we switched from ntp to chrony. However, since chrony conflicts with ntp, this change in dependency causes unattended-upgrades to skip upgrading freedombox. Switch to systemd-timesyncd, which does not conflict with either package. We can switch back to chrony after all users have upgraded to the most recent release. Closes #1486 Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
2e112d751c
commit
779ccb3bca
@ -27,13 +27,13 @@ from plinth.menu import main_menu
|
|||||||
|
|
||||||
from .manifest import backup
|
from .manifest import backup
|
||||||
|
|
||||||
version = 1
|
version = 2
|
||||||
|
|
||||||
is_essential = True
|
is_essential = True
|
||||||
|
|
||||||
managed_services = ['chrony']
|
managed_services = ['systemd-timesyncd']
|
||||||
|
|
||||||
managed_packages = ['chrony']
|
managed_packages = []
|
||||||
|
|
||||||
name = _('Date & Time')
|
name = _('Date & Time')
|
||||||
|
|
||||||
@ -55,36 +55,37 @@ def init():
|
|||||||
global service
|
global service
|
||||||
setup_helper = globals()['setup_helper']
|
setup_helper = globals()['setup_helper']
|
||||||
if setup_helper.get_state() != 'needs-setup':
|
if setup_helper.get_state() != 'needs-setup':
|
||||||
service = service_module.Service(
|
service = service_module.Service(managed_services[0], name,
|
||||||
managed_services[0], name, is_external=True)
|
is_external=True)
|
||||||
|
|
||||||
|
|
||||||
def setup(helper, old_version=None):
|
def setup(helper, old_version=None):
|
||||||
"""Install and configure the module."""
|
"""Install and configure the module."""
|
||||||
helper.install(managed_packages)
|
|
||||||
global service
|
global service
|
||||||
if service is None:
|
if service is None:
|
||||||
service = service_module.Service(
|
service = service_module.Service(managed_services[0], name,
|
||||||
managed_services[0], name, is_external=True)
|
is_external=True)
|
||||||
|
service.enable()
|
||||||
helper.call('post', service.notify_enabled, None, True)
|
helper.call('post', service.notify_enabled, None, True)
|
||||||
|
|
||||||
|
|
||||||
def diagnose():
|
def diagnose():
|
||||||
"""Run diagnostics and return the results."""
|
"""Run diagnostics and return the results."""
|
||||||
results = []
|
results = []
|
||||||
results.append(_diagnose_chrony_server_count())
|
results.append(_diagnose_time_synchronized())
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def _diagnose_chrony_server_count():
|
def _diagnose_time_synchronized():
|
||||||
"""Diagnose minimum chrony server count."""
|
"""Check whether time is synchronized to NTP server."""
|
||||||
result = 'failed'
|
result = 'failed'
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(['chronyc', '-c', 'sources'])
|
output = subprocess.check_output(
|
||||||
if output.decode():
|
['timedatectl', 'show', '--property=NTPSynchronized', '--value'])
|
||||||
|
if 'yes' in output.decode():
|
||||||
result = 'passed'
|
result = 'passed'
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return [_('chrony client in contact with servers'), result]
|
return [_('Time synchronized to NTP server'), result]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user