mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
upgrades: Use systemd service status instead of flag file
- A service with the same name can't be started again. - Transient service goes away as soon as the process ends. This is like automatically removing the flag. This ensures that stale file does not cause an issue. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
e58d3d8465
commit
9ddfbc4fed
@ -26,9 +26,6 @@ DIST_UPGRADE_PRE_DEBCONF_SELECTIONS: list[str] = [
|
|||||||
'grub-pc grub-pc/install_devices_empty boolean true'
|
'grub-pc grub-pc/install_devices_empty boolean true'
|
||||||
]
|
]
|
||||||
|
|
||||||
dist_upgrade_flag = pathlib.Path(
|
|
||||||
'/var/lib/freedombox/dist-upgrade-in-progress')
|
|
||||||
|
|
||||||
|
|
||||||
def _sources_list_update(old_codename: str, new_codename: str):
|
def _sources_list_update(old_codename: str, new_codename: str):
|
||||||
"""Change the distribution in /etc/apt/sources.list."""
|
"""Change the distribution in /etc/apt/sources.list."""
|
||||||
@ -89,7 +86,7 @@ def check(test_upgrade=False) -> tuple[bool, str]:
|
|||||||
Return (boolean, string) indicating if the upgrade is ready, and a reason
|
Return (boolean, string) indicating if the upgrade is ready, and a reason
|
||||||
if not.
|
if not.
|
||||||
"""
|
"""
|
||||||
if dist_upgrade_flag.exists():
|
if action_utils.service_is_running('freedombox-dist-upgrade'):
|
||||||
return (True, 'found-previous')
|
return (True, 'found-previous')
|
||||||
|
|
||||||
from plinth.modules.upgrades import get_current_release
|
from plinth.modules.upgrades import get_current_release
|
||||||
@ -112,8 +109,6 @@ def check(test_upgrade=False) -> tuple[bool, str]:
|
|||||||
|
|
||||||
_sources_list_update(dist, codename)
|
_sources_list_update(dist, codename)
|
||||||
|
|
||||||
logging.info('Dist upgrade in progress. Setting flag.')
|
|
||||||
dist_upgrade_flag.touch(mode=0o660)
|
|
||||||
return (True, 'started-dist-upgrade')
|
return (True, 'started-dist-upgrade')
|
||||||
|
|
||||||
|
|
||||||
@ -265,13 +260,6 @@ def _wait():
|
|||||||
time.sleep(10 * 60)
|
time.sleep(10 * 60)
|
||||||
|
|
||||||
|
|
||||||
def _flag_remove():
|
|
||||||
"""Remove the flag that mark that dist upgrade is running."""
|
|
||||||
print('Dist upgrade complete. Removing flag.', flush=True)
|
|
||||||
if dist_upgrade_flag.exists():
|
|
||||||
dist_upgrade_flag.unlink()
|
|
||||||
|
|
||||||
|
|
||||||
def perform():
|
def perform():
|
||||||
"""Perform upgrade to next release of Debian."""
|
"""Perform upgrade to next release of Debian."""
|
||||||
with _snapshot_run_and_disable(), \
|
with _snapshot_run_and_disable(), \
|
||||||
@ -287,7 +275,6 @@ def perform():
|
|||||||
_freedombox_restart()
|
_freedombox_restart()
|
||||||
_wait()
|
_wait()
|
||||||
_apt_update()
|
_apt_update()
|
||||||
_flag_remove()
|
|
||||||
|
|
||||||
|
|
||||||
def start_service():
|
def start_service():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user