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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-03-01 15:19:25 -08:00 committed by James Valleroy
parent ebca76b236
commit 2f0bc29239
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -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)