bind: Run setup

This commit is contained in:
mridulnagpal authored and James Valleroy committed 2017-01-06 18:17:11 -05:00
1 parent 17ed3f92c7
commit 4a73cbcf3c
3 files changed
+29 -32

No files matched your search

+27 -31
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():