From 2ae60802a9ae0d0d7e176141c21f8b82f611049b Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Tue, 5 Jan 2021 10:04:00 -0500 Subject: [PATCH] upgrades: Write dist-upgrade service file in /run Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- actions/upgrades | 20 ++++++++++++++++++- .../system/freedombox-dist-upgrade.service | 8 -------- 2 files changed, 19 insertions(+), 9 deletions(-) delete mode 100644 plinth/modules/upgrades/data/lib/systemd/system/freedombox-dist-upgrade.service diff --git a/actions/upgrades b/actions/upgrades index e4e87194d..d3b98063a 100755 --- a/actions/upgrades +++ b/actions/upgrades @@ -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, diff --git a/plinth/modules/upgrades/data/lib/systemd/system/freedombox-dist-upgrade.service b/plinth/modules/upgrades/data/lib/systemd/system/freedombox-dist-upgrade.service deleted file mode 100644 index a7362c874..000000000 --- a/plinth/modules/upgrades/data/lib/systemd/system/freedombox-dist-upgrade.service +++ /dev/null @@ -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