upgrades: Write dist-upgrade service file in /run

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2021-01-05 10:04:00 -05:00 committed by Sunil Mohan Adapa
parent 2e95077d74
commit 2ae60802a9
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 19 additions and 9 deletions

View File

@ -12,7 +12,7 @@ import subprocess
import sys
from plinth.action_utils import (apt_hold, debconf_set_selections,
run_apt_command)
run_apt_command, service_daemon_reload)
from plinth.modules.apache.components import check_url
from plinth.modules.upgrades import (BACKPORTS_SOURCES_LIST, SOURCES_LIST,
get_current_release, is_backports_current)
@ -76,6 +76,20 @@ Pin: release a=buster-backports
Pin-Priority: 500
'''
DIST_UPGRADE_SERVICE = '''
[Unit]
Description=Upgrade to new stable Debian release
[Service]
Type=oneshot
ExecStart=/usr/share/plinth/actions/upgrades dist-upgrade
KillMode=process
TimeoutSec=12hr
'''
DIST_UPGRADE_SERVICE_PATH = \
'/run/systemd/system/freedombox-dist-upgrade.service'
dist_upgrade_flag = pathlib.Path(
'/var/lib/freedombox/dist-upgrade-in-progress')
@ -457,6 +471,10 @@ def subcommand_start_dist_upgrade(arguments):
if updates are enabled.
"""
if _check_dist_upgrade(arguments.test):
with open(DIST_UPGRADE_SERVICE_PATH, 'w') as service_file:
service_file.write(DIST_UPGRADE_SERVICE)
service_daemon_reload()
subprocess.Popen(['systemctl', 'start', 'freedombox-dist-upgrade'],
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, close_fds=True,

View File

@ -1,8 +0,0 @@
[Unit]
Description=Upgrade to new stable Debian release
[Service]
Type=oneshot
ExecStart=/usr/share/plinth/actions/upgrades dist-upgrade
KillMode=process
TimeoutStopSec=900