mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
upgrades: Use internal scheduler instead of systemd timer
- For setting up backports repositories. Using an internal scheduler is easy to maintain in the long run. - Run it more frequently when in developer mode. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
94883b3c92
commit
50186eea6a
@ -9,7 +9,7 @@ from django.utils.translation import ugettext_noop
|
||||
import plinth
|
||||
from plinth import actions
|
||||
from plinth import app as app_module
|
||||
from plinth import menu
|
||||
from plinth import cfg, glib, menu
|
||||
|
||||
from .manifest import backup # noqa, pylint: disable=unused-import
|
||||
|
||||
@ -46,6 +46,11 @@ class UpgradesApp(app_module.App):
|
||||
|
||||
self._show_new_release_notification()
|
||||
|
||||
# Check every day for setting up apt backport sources, every 3 minutes
|
||||
# in debug mode.
|
||||
interval = 180 if cfg.develop else 24 * 3600
|
||||
glib.schedule(interval, _setup_repositories)
|
||||
|
||||
def _show_new_release_notification(self):
|
||||
"""When upgraded to new release, show a notification."""
|
||||
from plinth.notification import Notification
|
||||
@ -95,6 +100,10 @@ def setup(helper, old_version=None):
|
||||
# increment.
|
||||
helper.call('post', actions.superuser_run, 'upgrades', ['setup'])
|
||||
|
||||
# Try to setup apt repositories, if needed, if possible, on first install
|
||||
# and on version increment.
|
||||
helper.call('post', _setup_repositories, None)
|
||||
|
||||
|
||||
def is_enabled():
|
||||
"""Return whether the module is enabled."""
|
||||
@ -110,3 +119,8 @@ def enable():
|
||||
def disable():
|
||||
"""Disable the module."""
|
||||
actions.superuser_run('upgrades', ['disable-auto'])
|
||||
|
||||
|
||||
def _setup_repositories(data):
|
||||
"""Setup apt backport repositories."""
|
||||
actions.superuser_run('upgrades', ['setup-repositories'])
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
[Unit]
|
||||
Description=FreedomBox: Setup software repositories
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/share/plinth/actions/upgrades setup-repositories
|
||||
Type=oneshot
|
||||
LockPersonality=yes
|
||||
PrivateDevices=yes
|
||||
PrivateTmp=yes
|
||||
ProtectControlGroups=yes
|
||||
ProtectKernelLogs=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectKernelTunables=yes
|
||||
ProtectSystem=yes
|
||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||
RestrictRealtime=yes
|
||||
SystemCallArchitectures=native
|
||||
@ -1,12 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
[Unit]
|
||||
Description=FreedomBox: Daily check for setting up software repositories
|
||||
|
||||
[Timer]
|
||||
OnCalendar=daily
|
||||
AccuracySec=12h
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Loading…
x
Reference in New Issue
Block a user