summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-12 14:18:51 +0200
committerChristian Poessinger <christian@poessinger.com>2020-04-12 21:52:26 +0200
commit468a109e058b8b5e2d5b4db11ecab23d73c802fb (patch)
treeb648add2ba88f5d8cd7779f696de96cec42046de /src/conf_mode
parent7c27ad6480d99e7bd10e8ccb3c0a80d485d955ef (diff)
downloadvyos-1x-468a109e058b8b5e2d5b4db11ecab23d73c802fb.tar.gz
vyos-1x-468a109e058b8b5e2d5b4db11ecab23d73c802fb.zip
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.
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/dhcp_server.py15
1 files changed, 8 insertions, 7 deletions
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__':