mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +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 = '/etc/bind/named.conf.options'
|
||||||
CONFIG_FILE_2 = '/etc/bind/named_temp.conf.options'
|
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
"""Return parsed command line arguments as dictionary"""
|
"""Return parsed command line arguments as dictionary"""
|
||||||
@ -53,41 +52,38 @@ def subcommand_configure(arguments):
|
|||||||
|
|
||||||
|
|
||||||
def set_forwarding(choice):
|
def set_forwarding(choice):
|
||||||
"""Sets forwarding true/false"""
|
actions.superuser_run('bind', ['setup'])
|
||||||
if choice == False:
|
if choice == False:
|
||||||
flag = 0
|
flag = 0
|
||||||
f = open(CONFIG_FILE, 'r')
|
data = [line.strip() for line in open(CONFIG_FILE, 'r')]
|
||||||
w = open(CONFIG_FILE_2, 'w+')
|
if 'forwarders {' in data and not '// forwarders {' in data:
|
||||||
for line in f:
|
f = open(CONFIG_FILE, 'w')
|
||||||
if 'forwarders {' in line and not '// forwarders {' in line:
|
for line in data:
|
||||||
flag = 1
|
if 'forwarders {' in line and not '// forwarders {' in line:
|
||||||
if flag == 1:
|
flag = 1
|
||||||
line = ' //'+line
|
if flag == 1:
|
||||||
print(line)
|
line = ' //'+line
|
||||||
if 'forward only' in line:
|
if 'forward only' in line:
|
||||||
flag = 0
|
flag = 0
|
||||||
w.write(line)
|
f.write(line+'\n')
|
||||||
f.close()
|
f.close()
|
||||||
w.close()
|
|
||||||
os.rename('named.conf_temp.options', 'named.conf.options')
|
|
||||||
|
|
||||||
if choice == True:
|
if choice == True:
|
||||||
flag = 0
|
flag = 0
|
||||||
f = open(CONFIG_FILE, 'r')
|
data = [line.strip() for line in open(CONFIG_FILE, 'r')]
|
||||||
w = open(CONFIG_FILE_2, 'w+')
|
if '// forwarders {' in data:
|
||||||
for line in f:
|
f = open(CONFIG_FILE, 'w')
|
||||||
if '// forwarders {' in line:
|
for line in data:
|
||||||
print("yesy")
|
if '// forwarders {' in line:
|
||||||
flag = 1
|
flag = 1
|
||||||
if flag == 1:
|
if flag == 1:
|
||||||
line = line[3:]
|
line = line[2:]
|
||||||
print(line)
|
if 'forward only' in line:
|
||||||
if 'forward only' in line:
|
flag = 0
|
||||||
flag = 0
|
f.write(line+'\n')
|
||||||
w.write(line)
|
f.close()
|
||||||
f.close()
|
|
||||||
w.close()
|
|
||||||
os.rename('named.conf_temp.options', 'named.conf.options')
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@ -116,6 +116,7 @@ def diagnose():
|
|||||||
|
|
||||||
def default_config():
|
def default_config():
|
||||||
"""Initialize config file for BIND"""
|
"""Initialize config file for BIND"""
|
||||||
|
actions.superuser_run('bind', ['setup'])
|
||||||
f = open(CONFIG_FILE, "r")
|
f = open(CONFIG_FILE, "r")
|
||||||
contents = f.readlines()
|
contents = f.readlines()
|
||||||
f.close()
|
f.close()
|
||||||
|
|||||||
@ -30,7 +30,7 @@ from . import description, managed_services, get_default
|
|||||||
from .forms import BindForm
|
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."""
|
"""A specialized view for configuring minetest."""
|
||||||
service_id = managed_services[0]
|
service_id = managed_services[0]
|
||||||
diagnostics_module_name = "bind"
|
diagnostics_module_name = "bind"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user