mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
Use package framework for installing firewalld
This commit is contained in:
parent
9b9d112927
commit
d79f346591
@ -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'])
|
||||
|
||||
@ -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'
|
||||
|
||||
|
||||
@ -29,13 +29,7 @@ threat from the Internet.</p>
|
||||
|
||||
<p>The following is the current status:</p>
|
||||
|
||||
{% if firewall_status = 'not_installed' %}
|
||||
<p>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 <code>aptitude install firewalld</code></p>
|
||||
|
||||
{% elif firewall_status = 'not_running' %}
|
||||
{% if firewall_status = 'not_running' %}
|
||||
|
||||
<p>Firewall daemon is not running. Please run it. Firewall comes
|
||||
enabled by default on {{ cfg.box_name }}. On any Debian based system
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user