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