Commit 483980c6 authored by Ad Schellevis's avatar Ad Schellevis

(unbound_dhcpd) style fixes

parent b34f61cb
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
""" """
import os import os
import sys import sys
sys.path.insert(0, "/usr/local/opnsense/site-python") sys.path.insert(0, "/usr/local/opnsense/site-python")
import subprocess import subprocess
import time import time
...@@ -38,6 +39,7 @@ from daemonize import Daemonize ...@@ -38,6 +39,7 @@ from daemonize import Daemonize
import watchers.dhcpd import watchers.dhcpd
import params import params
def unbound_control(commands, output_stream=None): def unbound_control(commands, output_stream=None):
""" execute (chrooted) unbound-control command """ execute (chrooted) unbound-control command
:param commands: command list (parameters) :param commands: command list (parameters)
...@@ -45,8 +47,8 @@ def unbound_control(commands, output_stream=None): ...@@ -45,8 +47,8 @@ def unbound_control(commands, output_stream=None):
:return: None :return: None
""" """
output_stream = open(os.devnull, 'w') output_stream = open(os.devnull, 'w')
subprocess.check_call(['/usr/sbin/chroot', '-u', 'unbound', '-g' ,'unbound','/', subprocess.check_call(['/usr/sbin/chroot', '-u', 'unbound', '-g', 'unbound', '/',
'/usr/local/sbin/unbound-control','-c', '/var/unbound/unbound.conf'] + commands, '/usr/local/sbin/unbound-control', '-c', '/var/unbound/unbound.conf'] + commands,
stdout=output_stream, stderr=subprocess.STDOUT) stdout=output_stream, stderr=subprocess.STDOUT)
output_stream.seek(0) output_stream.seek(0)
...@@ -64,13 +66,15 @@ def unbound_known_addresses(): ...@@ -64,13 +66,15 @@ def unbound_known_addresses():
result.append(parts[4]) result.append(parts[4])
return result return result
# parse input params # parse input params
app_params={'pid': '/var/run/unbound_dhcpd.pid', app_params = {'pid': '/var/run/unbound_dhcpd.pid',
'domain': 'local', 'domain': 'local',
'target': '/var/unbound/dhcpleases.conf', 'target': '/var/unbound/dhcpleases.conf',
'background':'1'} 'background': '1'}
params.update_params(app_params) params.update_params(app_params)
def main(): def main():
# cleanup interval (seconds) # cleanup interval (seconds)
cleanup_interval = 60 cleanup_interval = 60
...@@ -118,6 +122,7 @@ def main(): ...@@ -118,6 +122,7 @@ def main():
# wait for next cycle # wait for next cycle
time.sleep(1) time.sleep(1)
# startup # startup
if app_params['background'] == '1': if app_params['background'] == '1':
daemon = Daemonize(app="unbound_dhcpd", pid=app_params['pid'], action=main) daemon = Daemonize(app="unbound_dhcpd", pid=app_params['pid'], action=main)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment