Commit c602a7fd authored by Franco Fichtner's avatar Franco Fichtner

services: simplify config writes

parent e8ccc540
...@@ -78,13 +78,6 @@ function bsnmpd_configure_do($verbose = false) ...@@ -78,13 +78,6 @@ function bsnmpd_configure_do($verbose = false)
flush(); flush();
} }
/* generate snmpd.conf */
$fd = fopen("/var/etc/snmpd.conf", "w");
if (!$fd) {
log_error('Cannot open snmpd.conf in bsnmpd_configure_do()');
return;
}
$snmpdconf = <<<EOD $snmpdconf = <<<EOD
location := "{$config['snmpd']['syslocation']}" location := "{$config['snmpd']['syslocation']}"
contact := "{$config['snmpd']['syscontact']}" contact := "{$config['snmpd']['syscontact']}"
...@@ -217,9 +210,7 @@ EOD; ...@@ -217,9 +210,7 @@ EOD;
} }
} }
fwrite($fd, $snmpdconf); file_put_contents('/var/etc/snmpd.conf', $snmpdconf);
fclose($fd);
unset($snmpdconf);
mwexec("/usr/sbin/bsnmpd -c /var/etc/snmpd.conf -p /var/run/snmpd.pid"); mwexec("/usr/sbin/bsnmpd -c /var/etc/snmpd.conf -p /var/run/snmpd.pid");
......
...@@ -287,7 +287,7 @@ function services_radvd_configure($blacklist = array()) ...@@ -287,7 +287,7 @@ function services_radvd_configure($blacklist = array())
$radvdconf .= "};\n"; $radvdconf .= "};\n";
} }
@file_put_contents('/var/etc/radvd.conf', $radvdconf); file_put_contents('/var/etc/radvd.conf', $radvdconf);
if (count($radvdifs) > 0) { if (count($radvdifs) > 0) {
if (isvalidpid('/var/run/radvd.pid')) { if (isvalidpid('/var/run/radvd.pid')) {
......
...@@ -182,15 +182,7 @@ function system_resolvconf_generate($dynupdate = false) ...@@ -182,15 +182,7 @@ function system_resolvconf_generate($dynupdate = false)
$dnslock = lock('resolvconf', LOCK_EX); $dnslock = lock('resolvconf', LOCK_EX);
$fd = fopen('/etc/resolv.conf', 'w'); file_put_contents('/etc/resolv.conf', $resolvconf);
if (!$fd) {
log_error('Cannot open resolv.conf in system_resolvconf_generate()');
unlock($dnslock);
return 1;
}
fwrite($fd, $resolvconf);
fclose($fd);
chmod('/etc/resolv.conf', 0644); chmod('/etc/resolv.conf', 0644);
if (!file_exists("/var/run/booting")) { if (!file_exists("/var/run/booting")) {
...@@ -810,13 +802,7 @@ EOD; ...@@ -810,13 +802,7 @@ EOD;
} }
} }
/* write syslog.conf */ file_put_contents('/var/etc/syslog.conf', $syslogconf);
if (!@file_put_contents("/var/etc/syslog.conf", $syslogconf)) {
log_error('Cannot open syslog.conf in system_syslogd_start()');
unset($syslogconf);
return 1;
}
unset($syslogconf);
if (!empty($syslogcfg['sourceip'])) { if (!empty($syslogcfg['sourceip'])) {
if ($syslogcfg['ipproto'] == "ipv6") { if ($syslogcfg['ipproto'] == "ipv6") {
...@@ -1683,11 +1669,7 @@ function system_ntp_configure($start_ntpd = true, $verbose = false) ...@@ -1683,11 +1669,7 @@ function system_ntp_configure($start_ntpd = true, $verbose = false)
} }
} }
/* open configuration for wrting or bail */ file_put_contents('/var/etc/ntpd.conf', $ntpcfg);
if (!@file_put_contents('/var/etc/ntpd.conf', $ntpcfg)) {
log_error("Could not open /var/etc/ntpd.conf for writing");
return;
}
if (!$start_ntpd) { if (!$start_ntpd) {
/* write out the config and delay startup */ /* write out the config and delay startup */
......
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