mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
upgrades: Refactor code for disabling Quassel during dist-upgrade
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
e97e1fc725
commit
0b807a8ce1
@ -8,10 +8,10 @@ import subprocess
|
|||||||
import time
|
import time
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
|
|
||||||
|
from plinth import action_utils
|
||||||
from plinth.action_utils import (apt_hold, apt_hold_freedombox,
|
from plinth.action_utils import (apt_hold, apt_hold_freedombox,
|
||||||
debconf_set_selections, run_apt_command,
|
debconf_set_selections, run_apt_command,
|
||||||
service_daemon_reload, service_is_running,
|
service_daemon_reload, service_restart)
|
||||||
service_restart, service_start, service_stop)
|
|
||||||
from plinth.modules import snapshot as snapshot_module
|
from plinth.modules import snapshot as snapshot_module
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
@ -170,20 +170,25 @@ def _snapshot_run_and_disable() -> Generator[None, None, None]:
|
|||||||
'before dist upgrade.')
|
'before dist upgrade.')
|
||||||
|
|
||||||
|
|
||||||
def perform():
|
@contextlib.contextmanager
|
||||||
"""Perform upgrade to next release of Debian."""
|
def _services_disable():
|
||||||
|
"""Disable services that are seriously impacted by the upgrade."""
|
||||||
# If quassel is running during dist upgrade, it may be restarted
|
# If quassel is running during dist upgrade, it may be restarted
|
||||||
# several times. This causes IRC users to rapidly leave/join
|
# several times. This causes IRC users to rapidly leave/join
|
||||||
# channels. Stop quassel for the duration of the dist upgrade.
|
# channels. Stop quassel for the duration of the dist upgrade.
|
||||||
quassel_service = 'quasselcore'
|
print('Stopping quassel service during dist upgrade...', flush=True)
|
||||||
quassel_was_running = service_is_running(quassel_service)
|
with action_utils.service_ensure_stopped('quasselcore'):
|
||||||
if quassel_was_running:
|
yield
|
||||||
print('Stopping quassel service before dist upgrade...', flush=True)
|
print('Re-enabling quassel service if previously enabled...',
|
||||||
service_stop(quassel_service)
|
flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
def perform():
|
||||||
|
"""Perform upgrade to next release of Debian."""
|
||||||
# Hold freedombox package during entire dist upgrade.
|
# Hold freedombox package during entire dist upgrade.
|
||||||
print('Holding freedombox package...', flush=True)
|
print('Holding freedombox package...', flush=True)
|
||||||
with apt_hold_freedombox(), _snapshot_run_and_disable():
|
with (apt_hold_freedombox(), _snapshot_run_and_disable(),
|
||||||
|
_services_disable()):
|
||||||
print('Updating Apt cache...', flush=True)
|
print('Updating Apt cache...', flush=True)
|
||||||
run_apt_command(['update'])
|
run_apt_command(['update'])
|
||||||
|
|
||||||
@ -217,11 +222,6 @@ def perform():
|
|||||||
'Apt full-upgrade was not successful. Distribution upgrade '
|
'Apt full-upgrade was not successful. Distribution upgrade '
|
||||||
'will be retried at a later time.')
|
'will be retried at a later time.')
|
||||||
|
|
||||||
if quassel_was_running:
|
|
||||||
print('Re-starting quassel service after dist upgrade...',
|
|
||||||
flush=True)
|
|
||||||
service_start(quassel_service)
|
|
||||||
|
|
||||||
print('Running apt autoremove...', flush=True)
|
print('Running apt autoremove...', flush=True)
|
||||||
run_apt_command(['autoremove'])
|
run_apt_command(['autoremove'])
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user