mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-17 18:14:42 +00:00
src: remove symlink trickery for /etc/hosts
This commit is contained in:
parent
5337532e52
commit
228eaee94b
@ -1755,7 +1755,7 @@ function services_dnsmasq_configure()
|
||||
$args = "";
|
||||
|
||||
if (isset($config['dnsmasq']['regdhcp'])) {
|
||||
$args .= " --dhcp-hostsfile={$g['varetc_path']}/hosts ";
|
||||
$args .= " --dhcp-hostsfile=/etc/hosts ";
|
||||
}
|
||||
|
||||
/* Setup listen port, if non-default */
|
||||
|
||||
@ -306,7 +306,7 @@ function system_hosts_generate()
|
||||
sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "TERM");
|
||||
@unlink("{$g['varrun_path']}/dhcpleases.pid");
|
||||
}
|
||||
$fd = fopen("{$g['varetc_path']}/hosts", "w");
|
||||
$fd = fopen('/etc/hosts', 'w');
|
||||
if (!$fd) {
|
||||
log_error("Error: cannot open hosts file in system_hosts_generate().\n");
|
||||
return 1;
|
||||
@ -333,20 +333,29 @@ function system_dhcpleases_configure()
|
||||
|| (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcp']))) {
|
||||
/* Make sure we do not error out */
|
||||
mwexec("/bin/mkdir -p {$g['dhcpd_chroot_path']}/var/db");
|
||||
if (!file_exists("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"))
|
||||
if (!file_exists("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases")) {
|
||||
@touch("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases");
|
||||
if (isvalidpid("{$g['varrun_path']}/dhcpleases.pid"))
|
||||
}
|
||||
if (isvalidpid("{$g['varrun_path']}/dhcpleases.pid")) {
|
||||
sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "HUP");
|
||||
else {
|
||||
} else {
|
||||
/* To ensure we do not start multiple instances of dhcpleases, perform some clean-up first. */
|
||||
if (is_process_running("dhcpleases"))
|
||||
mwexec('/bin/pkill dhcpleases');
|
||||
@unlink("{$g['varrun_path']}/dhcpleases.pid");
|
||||
if (isset($config['unbound']['enable']))
|
||||
$dns_pid = "unbound.pid";
|
||||
else
|
||||
$dns_pid = "dnsmasq.pid";
|
||||
mwexec("/usr/local/sbin/dhcpleases -l {$g['dhcpd_chroot_path']}/var/db/dhcpd.leases -d {$config['system']['domain']} -p {$g['varrun_path']}/{$dns_pid} -h {$g['varetc_path']}/hosts");
|
||||
killbyname('dhcpleases');
|
||||
@unlink('/var/run/dhcpleases.pid');
|
||||
if (isset($config['unbound']['enable'])) {
|
||||
$dns_pid = 'unbound.pid';
|
||||
} else {
|
||||
$dns_pid = 'dnsmasq.pid';
|
||||
}
|
||||
mwexecf(
|
||||
'/usr/local/sbin/dhcpleases -l %s -d %s -p %s -h %s',
|
||||
array(
|
||||
"{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases",
|
||||
$config['system']['domain'],
|
||||
"/var/run/{$dns_pid}",
|
||||
'/etc/hosts'
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "TERM");
|
||||
|
||||
@ -169,14 +169,9 @@ if [ ! -L /etc/syslog.conf ]; then
|
||||
/bin/ln -s /var/etc/syslog.conf /etc/syslog.conf
|
||||
fi
|
||||
|
||||
# Repair symlinks if they are broken
|
||||
if [ ! -L /etc/hosts ]; then
|
||||
/bin/rm -rf /etc/hosts
|
||||
/bin/ln -s /var/etc/hosts /etc/hosts
|
||||
fi
|
||||
|
||||
# Remove symlinks that are no longer needed
|
||||
if [ -L /etc/resolv.conf ]; then rm /etc/resolv.conf; fi
|
||||
if [ -L /etc/hosts ]; then /bin/rm /etc/hosts; fi
|
||||
|
||||
# Setup compatibility link for packages that
|
||||
# have trouble overriding the PREFIX configure
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user