Commit 42290252 authored by Franco Fichtner's avatar Franco Fichtner

dhcp: minor tweaks for configuration file readability

(cherry picked from commit ce6a5565)
(cherry picked from commit ce3bc611)
parent 64699782
......@@ -279,10 +279,7 @@ function services_radvd_configure($blacklist = array())
/* write radvd.conf */
if (!@file_put_contents("/var/etc/radvd.conf", $radvdconf)) {
log_error("Error: cannot open radvd.conf in services_radvd_configure().\n");
if (file_exists("/var/run/booting")) {
printf("Error: cannot open radvd.conf in services_radvd_configure().\n");
}
log_error('Cannot open radvd.conf in services_radvd_configure()');
}
if (count($radvdifs) > 0) {
......@@ -427,7 +424,6 @@ function services_dhcpdv4_configure()
}
}
$dhcpdconf = <<<EOD
option domain-name "{$config['system']['domain']}";
option ldap-server code 95 = text;
option domain-search-list code 119 = text;
......@@ -609,7 +605,7 @@ EOPP;
}
}
$dhcpdconf .= "subnet {$subnet} netmask {$subnetmask} {\n";
$dhcpdconf .= "\nsubnet {$subnet} netmask {$subnetmask} {\n";
// Setup pool options
foreach($all_pools as $poolconf) {
......@@ -780,8 +776,8 @@ EOD;
}
// Handle option, number rowhelper values
$dhcpdconf .= "\n";
if (isset($dhcpifconf['numberoptions']['item'])) {
$dhcpdconf .= "\n";
foreach($dhcpifconf['numberoptions']['item'] as $itemidx => $item) {
if (empty($item['type']) || $item['type'] == "text") {
$dhcpdconf .= " option custom-{$dhcpif}-{$itemidx} \"{$item['value']}\";\n";
......@@ -825,7 +821,7 @@ EOD;
/* add static mappings */
if (!empty($dhcpifconf['staticmap'])) {
foreach ($dhcpifconf['staticmap'] as $i => $sm) {
$dhcpdconf .= "host s_{$dhcpif}_{$i} {\n";
$dhcpdconf .= "\nhost s_{$dhcpif}_{$i} {\n";
if (!empty($sm['mac'])) {
$dhcpdconf .= " hardware ethernet {$sm['mac']};\n";
}
......@@ -925,7 +921,7 @@ EOD;
/* write dhcpd.conf */
if (!@file_put_contents("{$g['dhcpd_chroot_path']}/etc/dhcpd.conf", $dhcpdconf)) {
printf(gettext("Error: cannot open dhcpd.conf in services_dhcpdv4_configure().%s"), "\n");
log_error('Cannot open dhcpd.conf in services_dhcpdv4_configure()');
unset($dhcpdconf);
return 1;
}
......@@ -1124,7 +1120,6 @@ function services_dhcpdv6_configure($blacklist = array())
}
$dhcpdv6conf = <<<EOD
option domain-name "{$syscfg['domain']}";
option ldap-server code 95 = text;
option domain-search-list code 119 = text;
......@@ -1193,10 +1188,10 @@ EOD;
}
if (is_ipaddrv6($ifcfgipv6)) {
$dhcpdv6conf .= "subnet6 {$subnetv6}/{$ifcfgsnv6}";
$dhcpdv6conf .= "\nsubnet6 {$subnetv6}/{$ifcfgsnv6}";
} else {
$subnet6 = gen_subnetv6($dhcpv6ifconf['range']['from'], "64");
$dhcpdv6conf .= "subnet6 {$subnet6}/64";
$dhcpdv6conf .= "\nsubnet6 {$subnet6}/64";
}
$dhcpdv6conf .= " {\n";
......@@ -1236,8 +1231,8 @@ EOD;
}
// Handle option, number rowhelper values
$dhcpdv6conf .= "\n";
if (isset($dhcpv6ifconf['numberoptions']['item'])) {
$dhcpdv6conf .= "\n";
foreach($dhcpv6ifconf['numberoptions']['item'] as $itemv6idx => $itemv6) {
$dhcpdv6conf .= " option custom-{$dhcpv6if}-{$itemv6idx} \"{$itemv6['value']}\";\n";
}
......@@ -1263,6 +1258,7 @@ EOD;
$i = 0;
foreach ($dhcpv6ifconf['staticmap'] as $sm) {
$dhcpdv6conf .= <<<EOD
host s_{$dhcpv6if}_{$i} {
host-identifier option dhcp6.client-id {$sm['duid']};
......@@ -1321,18 +1317,15 @@ EOD;
}
if ($nsupdate) {
$dhcpdv6conf .= "ddns-update-style interim;\n";
$dhcpdv6conf .= "\nddns-update-style interim;\n";
$dhcpdv6conf .= services_dhcpd_zones($ddns_zones);
} else {
$dhcpdv6conf .= "ddns-update-style none;\n";
$dhcpdv6conf .= "\nddns-update-style none;\n";
}
/* write dhcpdv6.conf */
if (!@file_put_contents("{$g['dhcpd_chroot_path']}/etc/dhcpdv6.conf", $dhcpdv6conf)) {
log_error("Error: cannot open {$g['dhcpd_chroot_path']}/etc/dhcpdv6.conf in services_dhcpdv6_configure().\n");
if (file_exists("/var/run/booting")) {
printf("Error: cannot open {$g['dhcpd_chroot_path']}/etc/dhcpdv6.conf in services_dhcpdv6_configure().\n");
}
log_error("Cannot open {$g['dhcpd_chroot_path']}/etc/dhcpdv6.conf in services_dhcpdv6_configure()");
unset($dhcpdv6conf);
return 1;
}
......
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