From 468a109e058b8b5e2d5b4db11ecab23d73c802fb Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 12 Apr 2020 14:18:51 +0200 Subject: dhcp-server: T2185: create directories in /run on-demand Commit bc68244 ("dhcp-server: T2185: migrate from SysVinit to systemd") migrated the DHCP subsystem to systemd, necessary directories in the volatile /run directory have not been created. --- src/conf_mode/dhcp_server.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/dhcp_server.py b/src/conf_mode/dhcp_server.py index aaa5ad3b3..39f2921cd 100755 --- a/src/conf_mode/dhcp_server.py +++ b/src/conf_mode/dhcp_server.py @@ -24,8 +24,8 @@ from sys import exit from vyos.config import Config from vyos.validate import is_subnet_connected from vyos import ConfigError -from vyos.util import call from vyos.template import render +from vyos.util import call, chown config_file = r'/run/dhcp-server/dhcpd.conf' @@ -445,7 +445,7 @@ def get_config(): return dhcp def verify(dhcp): - if (dhcp is None) or (dhcp['disabled'] is True): + if not dhcp or dhcp['disabled']: return None # If DHCP is enabled we need one share-network @@ -591,12 +591,12 @@ def verify(dhcp): return None def generate(dhcp): - if not dhcp: + if not dhcp or dhcp['disabled']: return None - if dhcp['disabled'] is True: - print('Warning: DHCP server will be deactivated because it is disabled') - return None + dirname = os.path.dirname(config_file) + if not os.path.isdir(dirname): + os.mkdir(dirname) # Please see: https://phabricator.vyos.net/T1129 for quoting of the raw parameters # we can pass to ISC DHCPd @@ -610,8 +610,9 @@ def apply(dhcp): call('systemctl stop isc-dhcp-server.service') if os.path.exists(config_file): os.unlink(config_file) + return None - call('systemctl restart isc-dhcp-server.service') + call('systemctl restart isc-dhcp-server.service') return None if __name__ == '__main__': -- cgit v1.2.3