From d79f346591222468552e38e71ad1c6422c46df00 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 22 Dec 2014 23:27:16 +0530 Subject: [PATCH] Use package framework for installing firewalld --- actions/firewall | 12 ------------ plinth/modules/firewall/firewall.py | 15 +++------------ plinth/modules/firewall/templates/firewall.html | 8 +------- 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/actions/firewall b/actions/firewall index 98d40fe8d..cae05e86c 100755 --- a/actions/firewall +++ b/actions/firewall @@ -30,10 +30,6 @@ def parse_arguments(): parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(dest='subcommand', help='Sub command') - # Get installed status - subparsers.add_parser('get-installed', - help='Get whether firewalld is installed') - # Get status subparsers.add_parser('get-status', help='Get whether firewalld is running') @@ -64,14 +60,6 @@ def parse_arguments(): return parser.parse_args() -def subcommand_get_installed(_): - """Print whether firewalld is installed""" - with open('/dev/null', 'w') as file_handle: - status = subprocess.call(['which', 'firewalld'], stdout=file_handle) - - print('installed' if not status else 'not installed') - - def subcommand_get_status(_): """Print status of the firewalld service""" subprocess.call(['firewall-cmd', '--state']) diff --git a/plinth/modules/firewall/firewall.py b/plinth/modules/firewall/firewall.py index 906573286..189762255 100644 --- a/plinth/modules/firewall/firewall.py +++ b/plinth/modules/firewall/firewall.py @@ -26,6 +26,7 @@ import logging from plinth import actions from plinth import cfg +from plinth import package from plinth.signals import service_enabled import plinth.service as service_module @@ -42,13 +43,9 @@ def init(): @login_required +@package.required('firewalld') def index(request): """Serve introcution page""" - if not get_installed_status(): - return TemplateResponse(request, 'firewall.html', - {'title': _('Firewall'), - 'firewall_status': 'not_installed'}) - if not get_enabled_status(): return TemplateResponse(request, 'firewall.html', {'title': _('Firewall'), @@ -65,14 +62,8 @@ def index(request): 'external_enabled_services': external_enabled_services}) -def get_installed_status(): - """Return whether firewall is installed""" - output = _run(['get-installed'], superuser=True) - return output.split()[0] == 'installed' - - def get_enabled_status(): - """Return whether firewall is installed""" + """Return whether firewall is enabled""" output = _run(['get-status'], superuser=True) return output.split()[0] == 'running' diff --git a/plinth/modules/firewall/templates/firewall.html b/plinth/modules/firewall/templates/firewall.html index aa4ea3eb6..5eac0b6db 100644 --- a/plinth/modules/firewall/templates/firewall.html +++ b/plinth/modules/firewall/templates/firewall.html @@ -29,13 +29,7 @@ threat from the Internet.

The following is the current status:

-{% if firewall_status = 'not_installed' %} -

Firewall is not installed. Please install it. Firewall comes -pre-installed with {{ cfg.box_name }}. On any Debian based system (such -as {{ cfg.box_name }}) you may install it using the -command aptitude install firewalld

- -{% elif firewall_status = 'not_running' %} +{% if firewall_status = 'not_running' %}

Firewall daemon is not running. Please run it. Firewall comes enabled by default on {{ cfg.box_name }}. On any Debian based system