From 95265426a93182245ab41fd391b417e6546e8616 Mon Sep 17 00:00:00 2001 From: mridulnagpal Date: Thu, 29 Dec 2016 05:43:26 +0530 Subject: [PATCH] bind: Move setup to action script --- actions/bind | 16 ++++++++++++++++ plinth/modules/bind/__init__.py | 16 +++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/actions/bind b/actions/bind index c09226922..dc4f847a5 100755 --- a/actions/bind +++ b/actions/bind @@ -32,6 +32,7 @@ def parse_arguments(): """Return parsed command line arguments as dictionary""" parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(dest='subcommand', help='Sub command') + subparsers.add_parser('setup', help='Setup for BIND') configure = subparsers.add_parser('configure', help='Configure Minetest') configure.add_argument('--set-forwarding', choices=['true', 'false'], @@ -42,6 +43,21 @@ def parse_arguments(): return parser.parse_args() +def subcommand_setup(_): + """Setup BIND configuration.""" + f = open(CONFIG_FILE, "r") + contents = f.readlines() + f.close() + + contents.insert(0, value1) + contents.insert(4, value2) + contents.insert(15, value3) + + f = open(CONFIG_FILE, "w") + contents = "".join(contents) + f.write(contents) + f.close() + def subcommand_configure(arguments): """Configure BIND.""" diff --git a/plinth/modules/bind/__init__.py b/plinth/modules/bind/__init__.py index 78174ec5a..9ab4ee83d 100644 --- a/plinth/modules/bind/__init__.py +++ b/plinth/modules/bind/__init__.py @@ -113,22 +113,12 @@ def diagnose(): results.append(action_utils.diagnose_port_listening(53, 'udp6')) return results + def default_config(): - """Initialize config file for BIND""" + """Setp BIND configuration""" actions.superuser_run('bind', ['setup']) - f = open(CONFIG_FILE, "r") - contents = f.readlines() - f.close() - - contents.insert(0, value1) - contents.insert(4, value2) - contents.insert(15, value3) - - f = open(CONFIG_FILE, "w") - contents = "".join(contents) - f.write(contents) - f.close() + def get_default(): """Get initial value for forwarding"""