bind: Run setup

This commit is contained in:
mridulnagpal 2016-12-28 22:58:31 +05:30 committed by James Valleroy
parent 17ed3f92c7
commit 4a73cbcf3c
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
3 changed files with 29 additions and 32 deletions

View File

@ -27,7 +27,6 @@ from plinth import action_utils
CONFIG_FILE = '/etc/bind/named.conf.options'
CONFIG_FILE_2 = '/etc/bind/named_temp.conf.options'
def parse_arguments():
"""Return parsed command line arguments as dictionary"""
@ -53,41 +52,38 @@ def subcommand_configure(arguments):
def set_forwarding(choice):
"""Sets forwarding true/false"""
actions.superuser_run('bind', ['setup'])
if choice == False:
flag = 0
f = open(CONFIG_FILE, 'r')
w = open(CONFIG_FILE_2, 'w+')
for line in f:
if 'forwarders {' in line and not '// forwarders {' in line:
flag = 1
if flag == 1:
line = ' //'+line
print(line)
if 'forward only' in line:
flag = 0
w.write(line)
f.close()
w.close()
os.rename('named.conf_temp.options', 'named.conf.options')
data = [line.strip() for line in open(CONFIG_FILE, 'r')]
if 'forwarders {' in data and not '// forwarders {' in data:
f = open(CONFIG_FILE, 'w')
for line in data:
if 'forwarders {' in line and not '// forwarders {' in line:
flag = 1
if flag == 1:
line = ' //'+line
if 'forward only' in line:
flag = 0
f.write(line+'\n')
f.close()
if choice == True:
flag = 0
f = open(CONFIG_FILE, 'r')
w = open(CONFIG_FILE_2, 'w+')
for line in f:
if '// forwarders {' in line:
print("yesy")
flag = 1
if flag == 1:
line = line[3:]
print(line)
if 'forward only' in line:
flag = 0
w.write(line)
f.close()
w.close()
os.rename('named.conf_temp.options', 'named.conf.options')
data = [line.strip() for line in open(CONFIG_FILE, 'r')]
if '// forwarders {' in data:
f = open(CONFIG_FILE, 'w')
for line in data:
if '// forwarders {' in line:
flag = 1
if flag == 1:
line = line[2:]
if 'forward only' in line:
flag = 0
f.write(line+'\n')
f.close()
def main():

View File

@ -116,6 +116,7 @@ def diagnose():
def default_config():
"""Initialize config file for BIND"""
actions.superuser_run('bind', ['setup'])
f = open(CONFIG_FILE, "r")
contents = f.readlines()
f.close()

View File

@ -30,7 +30,7 @@ from . import description, managed_services, get_default
from .forms import BindForm
class MinetestServiceView(ServiceView): # pylint: disable=too-many-ancestors
class BindServiceView(ServiceView): # pylint: disable=too-many-ancestors
"""A specialized view for configuring minetest."""
service_id = managed_services[0]
diagnostics_module_name = "bind"