From 2f0bc2923981a09bc746f24cd59fd34f8ad37502 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 1 Mar 2019 15:19:25 -0800 Subject: [PATCH] firewalld: Implement upgrading from 0.4.x to 0.6.x - firewalld is always on an active. Running setup is not a problem. - Installing new configuration and applying changes on top is more reliable. Changes to be done are not configuration settings but FreedomBox defaults. Fixes: #1367. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/firewall/__init__.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plinth/modules/firewall/__init__.py b/plinth/modules/firewall/__init__.py index 763528641..c0fc801de 100644 --- a/plinth/modules/firewall/__init__.py +++ b/plinth/modules/firewall/__init__.py @@ -26,7 +26,7 @@ import plinth.service as service_module from plinth import actions, cfg from plinth.menu import main_menu from plinth.signals import service_enabled -from plinth.utils import format_lazy +from plinth.utils import Version, format_lazy from .manifest import backup @@ -65,6 +65,21 @@ def setup(helper, old_version=None): _run(['setup'], superuser=True) +def force_upgrade(helper, packages): + """Force upgrade firewalld to resolve conffile prompts.""" + if 'firewalld' not in packages: + return + + # firewalld 0.4.4.6-2 -> 0.6.x + package = packages['firewalld'] + if Version(package['current_version']) >= Version('0.6') or \ + Version(package['new_version']) < Version('0.6'): + return + + helper.install(['firewalld'], force_configuration='new') + _run(['setup'], superuser=True) + + def get_enabled_status(): """Return whether firewall is enabled""" output = _run(['get-status'], superuser=True)