package/dhcp/S80dhcp-*: possible bug
Hi all,
The S80dhcp-* scripts use string variables like INTERFACES that are left empty. Because of that, the corresponding services are not started.
Previously, there were configuration files to initialize these variables, but they have been removed by the commit 07064c0978b78356bf74408c216f524881df3362.
Is it a bug, or are these scripts supposed to just be templates (requiring a root FS overlay to fix them) and not the actual scripts?
If it is a bug, what is the preferred way of fixing it? With a configuration file that would be sourced by these scripts like before, or with Config.in string options that would fill these scripts, or with something else?
Best regards,
Beno?t
PATCH 1/3 package/dhcp: fix SysV init scripts option passing
The SysV init scripts have configuration variables like INTERFACES whose contents have to be passed to the daemon. These variables are initialized as empty strings, but some of them are not allowed to be empty and there was no means of filling them apart from creating a root FS overlay to overwrite these scripts.
This commit adds support for files under /etc/default/ to set these configuration variables. Such light files can now be added to the root FS skeleton or overlays without having to duplicate most of the SysV init scripts.
--- package/dhcp/S80dhcp-relay | 4 ++++ package/dhcp/S80dhcp-server | 4 ++++ 2 files changed, 8 insertions(+)
package/dhcp/S80dhcp-relay +4 -0
@@ -13,6 +13,10 @@ INTERFACES="" # Additional options that are passed to the DHCP relay daemon? OPTIONS="" +# Read configuration variable file if it is present +CFG_FILE="/etc/default/dhcrelay" +[ -r "${CFG_FILE}" ] && . "${CFG_FILE}" + # Sanity checks test -f /usr/sbin/dhcrelay || exit 0 test -n "$INTERFACES" || exit 0
package/dhcp/S80dhcp-server +4 -0
@@ -7,6 +7,10 @@ # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACES="" +# Read configuration variable file if it is present +CFG_FILE="/etc/default/dhcpd" +[ -r "${CFG_FILE}" ] && . "${CFG_FILE}" + # Sanity checks test -f /usr/sbin/dhcpd || exit 0 test -f /etc/dhcp/dhcpd.conf || exit 0
Signature · 1 line
2.1.4
PATCH 2/3 package/dhcp/S80dhcp-server: support extra options
Add an OPTIONS configuration variable in order to make it possible to pass custom extra options to dhcpd.
--- package/dhcp/S80dhcp-server | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
package/dhcp/S80dhcp-server +4 -1
@@ -7,6 +7,9 @@ # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACES="" +# Additional options that are passed to the DHCP server daemon? +OPTIONS="" + # Read configuration variable file if it is present CFG_FILE="/etc/default/dhcpd" [ -r "${CFG_FILE}" ] && . "${CFG_FILE}"
@@ -21,7 +24,7 @@ case "$1" in echo -n "Starting DHCP server: " test -d /var/lib/dhcp/ || mkdir -p /var/lib/dhcp/ test -f /var/lib/dhcp/dhcpd.leases || touch /var/lib/dhcp/dhcpd.leases - start-stop-daemon -S -x /usr/sbin/dhcpd -- -q $INTERFACES + start-stop-daemon -S -x /usr/sbin/dhcpd -- -q $OPTIONS $INTERFACES [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop)
Signature · 1 line
2.1.4
PATCH 3/3 package/dhcp/S80dhcp-server: allow empty INTERFACES
In reply to Benoît ThébaudeauThe dhcpd daemon does not require network interface names to be specified on the command line.
From dhcpd(8):
"The names of the network interfaces on which dhcpd should listen for broadcasts may be specified on the command line. This should be done on systems where dhcpd is unable to identify non-broadcast interfaces, but should not be required on other systems. If no interface names are specified on the command line dhcpd will identify all network interfaces which are up, eliminating non-broadcast interfaces if possible, and listen for DHCP broadcasts on each interface."
dhcpd exits with "Not configured to listen on any interfaces!" only if no requested (those in INTERFACES, or all if empty) non-broadcast interfaces matching the subnet declarations in dhcpd.conf are up.
--- package/dhcp/S80dhcp-server | 1 - 1 file changed, 1 deletion(-)
package/dhcp/S80dhcp-server +0 -1
@@ -17,7 +17,6 @@ CFG_FILE="/etc/default/dhcpd" # Sanity checks test -f /usr/sbin/dhcpd || exit 0 test -f /etc/dhcp/dhcpd.conf || exit 0 -test -n "$INTERFACES" || exit 0 case "$1" in start)
Signature · 1 line
2.1.4