[#759] Add fail2ban to Plinth UI

Run sudo-required action via actions.superuser_run

Actions related to services those require `sudo` permissions need to
be executed via actions.superuser_run.

NOTE:
If plinth service is started via `sudo ./run --debug` (in dev mode)
all actions will be executed silently. But plinth in user machines
won't be executed with sudo permissions.
This commit is contained in:
nsaikiran authored and James Valleroy committed 2017-07-29 09:42:31 -04:00
1 parent 09f3f23e10
commit a8a5da996e
5 files changed
+42 -2

No files matched your search

+6
View File
@@ -36,6 +36,7 @@ def add_service_action(subparsers, action, help):
parser = subparsers.add_parser(action, help=help)
parser.add_argument('service', help='name of the service')
def parse_arguments():
"""Return parsed command line arguments as dictionary."""
parser = argparse.ArgumentParser()
@@ -48,6 +49,7 @@ def parse_arguments():
add_service_action(subparsers, 'reload', 'reload a service')
add_service_action(subparsers, 'is-running', 'status of a service')
add_service_action(subparsers, 'is-enabled', 'status a service')
add_service_action(subparsers, 'unmask', 'unmask a service')
subparsers.add_parser('list', help='List of running system services')
@@ -75,6 +77,10 @@ def subcommand_reload(arguments):
action_utils.service_reload(arguments.service)
def subcommand_unmask(arguments):
action_utils.service_unmask(arguments.service)
def subcommand_is_enabled(arguments):
print(action_utils.service_is_enabled(arguments.service))