mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
bind: Run setup
This commit is contained in:
parent
17ed3f92c7
commit
4a73cbcf3c
58
actions/bind
58
actions/bind
@ -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():
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user