* [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing
2015-08-21 16:45 [Buildroot] [PATCH v2 0/8] package/dhcp: rework the SysV init scripts Benoît Thébaudeau
@ 2015-08-21 16:45 ` Benoît Thébaudeau
0 siblings, 0 replies; 13+ messages in thread
From: Benoît Thébaudeau @ 2015-08-21 16:45 UTC (permalink / raw)
To: buildroot
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.
Signed-off-by: Beno?t Th?baudeau <benoit@wsystem.com>
---
package/dhcp/S80dhcp-relay | 4 ++++
package/dhcp/S80dhcp-server | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/package/dhcp/S80dhcp-relay b/package/dhcp/S80dhcp-relay
index 9faa13d..74ec63c 100755
--- a/package/dhcp/S80dhcp-relay
+++ b/package/dhcp/S80dhcp-relay
@@ -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
diff --git a/package/dhcp/S80dhcp-server b/package/dhcp/S80dhcp-server
index fb99f9a..b9c47ba 100755
--- a/package/dhcp/S80dhcp-server
+++ b/package/dhcp/S80dhcp-server
@@ -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
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing
@ 2015-10-13 9:35 Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 2/8] package/dhcp/S80dhcp-server: support extra options Benoît Thébaudeau
` (7 more replies)
0 siblings, 8 replies; 13+ messages in thread
From: Benoît Thébaudeau @ 2015-10-13 9:35 UTC (permalink / raw)
To: buildroot
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.
Signed-off-by: Beno?t Th?baudeau <benoit@wsystem.com>
---
Changes v1 -> v2:
- Rebase.
---
package/dhcp/S80dhcp-relay | 4 ++++
package/dhcp/S80dhcp-server | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/package/dhcp/S80dhcp-relay b/package/dhcp/S80dhcp-relay
index 5ee06c7..0f383e6 100755
--- a/package/dhcp/S80dhcp-relay
+++ b/package/dhcp/S80dhcp-relay
@@ -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
diff --git a/package/dhcp/S80dhcp-server b/package/dhcp/S80dhcp-server
index 3df14ff..f7907e2 100755
--- a/package/dhcp/S80dhcp-server
+++ b/package/dhcp/S80dhcp-server
@@ -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
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Buildroot] [PATCH v2 2/8] package/dhcp/S80dhcp-server: support extra options
2015-10-13 9:35 [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Benoît Thébaudeau
@ 2015-10-13 9:35 ` Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 3/8] package/dhcp/S80dhcp-server: allow empty INTERFACES Benoît Thébaudeau
` (6 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Benoît Thébaudeau @ 2015-10-13 9:35 UTC (permalink / raw)
To: buildroot
Add an OPTIONS configuration variable in order to make it possible to
pass custom extra options to dhcpd.
Signed-off-by: Beno?t Th?baudeau <benoit@wsystem.com>
---
Changes v1 -> v2:
- Rebase.
---
package/dhcp/S80dhcp-server | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/package/dhcp/S80dhcp-server b/package/dhcp/S80dhcp-server
index f7907e2..c1ef53b 100755
--- a/package/dhcp/S80dhcp-server
+++ b/package/dhcp/S80dhcp-server
@@ -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
printf "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)
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Buildroot] [PATCH v2 3/8] package/dhcp/S80dhcp-server: allow empty INTERFACES
2015-10-13 9:35 [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 2/8] package/dhcp/S80dhcp-server: support extra options Benoît Thébaudeau
@ 2015-10-13 9:35 ` Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 4/8] package/dhcp: fix SysV init scripts output text Benoît Thébaudeau
` (5 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Benoît Thébaudeau @ 2015-10-13 9:35 UTC (permalink / raw)
To: buildroot
The 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.
Signed-off-by: Beno?t Th?baudeau <benoit@wsystem.com>
---
Changes v1 -> v2:
- Rebase.
---
package/dhcp/S80dhcp-server | 1 -
1 file changed, 1 deletion(-)
diff --git a/package/dhcp/S80dhcp-server b/package/dhcp/S80dhcp-server
index c1ef53b..079727b 100755
--- a/package/dhcp/S80dhcp-server
+++ b/package/dhcp/S80dhcp-server
@@ -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)
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Buildroot] [PATCH v2 4/8] package/dhcp: fix SysV init scripts output text
2015-10-13 9:35 [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 2/8] package/dhcp/S80dhcp-server: support extra options Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 3/8] package/dhcp/S80dhcp-server: allow empty INTERFACES Benoît Thébaudeau
@ 2015-10-13 9:35 ` Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 5/8] package/dhcp: remove sleep from SysV init scripts restart Benoît Thébaudeau
` (4 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Benoît Thébaudeau @ 2015-10-13 9:35 UTC (permalink / raw)
To: buildroot
Fix various messages displayed by these scripts:
- remove extra "dhcpd3" for `S80dhcp-server stop`,
- make start-stop-daemon quiet in order to avoid extra messages like
"stopped /usr/sbin/dhcpd (pid 174)" being output between the command
description and its result,
- fix the script names in the usage strings.
Signed-off-by: Beno?t Th?baudeau <benoit@wsystem.com>
---
Changes v1 -> v2:
- Rebase.
- Use 'printf' instead of 'echo -n' following
0f75b2635ee564fbbdb9ea631cf39fa8731d6d6c.
---
package/dhcp/S80dhcp-relay | 6 +++---
package/dhcp/S80dhcp-server | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/package/dhcp/S80dhcp-relay b/package/dhcp/S80dhcp-relay
index 0f383e6..6493eda 100755
--- a/package/dhcp/S80dhcp-relay
+++ b/package/dhcp/S80dhcp-relay
@@ -33,12 +33,12 @@ DHCRELAYPID=/var/run/dhcrelay.pid
case "$1" in
start)
printf "Starting DHCP relay: "
- start-stop-daemon -S -x /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS
+ start-stop-daemon -S -q -x /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
stop)
printf "Stopping DHCP relay: "
- start-stop-daemon -K -x /usr/sbin/dhcrelay
+ start-stop-daemon -K -q -x /usr/sbin/dhcrelay
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
restart | force-reload)
@@ -47,7 +47,7 @@ case "$1" in
$0 start
;;
*)
- echo "Usage: /etc/init.d/dhcp-relay {start|stop|restart|force-reload}"
+ echo "Usage: $0 {start|stop|restart|force-reload}"
exit 1
esac
diff --git a/package/dhcp/S80dhcp-server b/package/dhcp/S80dhcp-server
index 079727b..c56e7c3 100755
--- a/package/dhcp/S80dhcp-server
+++ b/package/dhcp/S80dhcp-server
@@ -23,12 +23,12 @@ case "$1" in
printf "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 $OPTIONS $INTERFACES
+ start-stop-daemon -S -q -x /usr/sbin/dhcpd -- -q $OPTIONS $INTERFACES
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
stop)
- printf "Stopping DHCP server: dhcpd3"
- start-stop-daemon -K -x /usr/sbin/dhcpd
+ printf "Stopping DHCP server: "
+ start-stop-daemon -K -q -x /usr/sbin/dhcpd
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
restart | force-reload)
@@ -40,7 +40,7 @@ case "$1" in
fi
;;
*)
- echo "Usage: /etc/init.d/dhcp-server {start|stop|restart|force-reload}"
+ echo "Usage: $0 {start|stop|restart|force-reload}"
exit 1
esac
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Buildroot] [PATCH v2 5/8] package/dhcp: remove sleep from SysV init scripts restart
2015-10-13 9:35 [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Benoît Thébaudeau
` (2 preceding siblings ...)
2015-10-13 9:35 ` [Buildroot] [PATCH v2 4/8] package/dhcp: fix SysV init scripts output text Benoît Thébaudeau
@ 2015-10-13 9:35 ` Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 6/8] package/dhcp: SysV init scripts: remove PID files after stop Benoît Thébaudeau
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Benoît Thébaudeau @ 2015-10-13 9:35 UTC (permalink / raw)
To: buildroot
No sleep is required for the restart and force-reload operations to
succeed.
Signed-off-by: Beno?t Th?baudeau <benoit@wsystem.com>
---
Changes v1 -> v2:
- Rebase.
---
package/dhcp/S80dhcp-relay | 1 -
package/dhcp/S80dhcp-server | 1 -
2 files changed, 2 deletions(-)
diff --git a/package/dhcp/S80dhcp-relay b/package/dhcp/S80dhcp-relay
index 6493eda..211431b 100755
--- a/package/dhcp/S80dhcp-relay
+++ b/package/dhcp/S80dhcp-relay
@@ -43,7 +43,6 @@ case "$1" in
;;
restart | force-reload)
$0 stop
- sleep 2
$0 start
;;
*)
diff --git a/package/dhcp/S80dhcp-server b/package/dhcp/S80dhcp-server
index c56e7c3..dc9c433 100755
--- a/package/dhcp/S80dhcp-server
+++ b/package/dhcp/S80dhcp-server
@@ -33,7 +33,6 @@ case "$1" in
;;
restart | force-reload)
$0 stop
- sleep 2
$0 start
if [ "$?" != "0" ]; then
exit 1
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Buildroot] [PATCH v2 6/8] package/dhcp: SysV init scripts: remove PID files after stop
2015-10-13 9:35 [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Benoît Thébaudeau
` (3 preceding siblings ...)
2015-10-13 9:35 ` [Buildroot] [PATCH v2 5/8] package/dhcp: remove sleep from SysV init scripts restart Benoît Thébaudeau
@ 2015-10-13 9:35 ` Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 7/8] package/dhcp/S80dhcp-server: support IPv6 lease file Benoît Thébaudeau
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Benoît Thébaudeau @ 2015-10-13 9:35 UTC (permalink / raw)
To: buildroot
These daemons do not remove their PID files, so do it manually in the
scripts.
Signed-off-by: Beno?t Th?baudeau <benoit@wsystem.com>
---
Changes v1 -> v2:
- Rebase.
---
package/dhcp/S80dhcp-relay | 12 ++++++++++--
package/dhcp/S80dhcp-server | 12 ++++++++++--
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/package/dhcp/S80dhcp-relay b/package/dhcp/S80dhcp-relay
index 211431b..9b8d65f 100755
--- a/package/dhcp/S80dhcp-relay
+++ b/package/dhcp/S80dhcp-relay
@@ -17,6 +17,9 @@ OPTIONS=""
CFG_FILE="/etc/default/dhcrelay"
[ -r "${CFG_FILE}" ] && . "${CFG_FILE}"
+# PID files generated by the daemon
+PID_FILES="/var/run/dhcrelay.pid /var/run/dhcrelay6.pid"
+
# Sanity checks
test -f /usr/sbin/dhcrelay || exit 0
test -n "$INTERFACES" || exit 0
@@ -38,8 +41,13 @@ case "$1" in
;;
stop)
printf "Stopping DHCP relay: "
- start-stop-daemon -K -q -x /usr/sbin/dhcrelay
- [ $? = 0 ] && echo "OK" || echo "FAIL"
+ if start-stop-daemon -K -q -x /usr/sbin/dhcrelay; then
+ # This daemon does not remove its PID file when it exits.
+ rm -f ${PID_FILES}
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
;;
restart | force-reload)
$0 stop
diff --git a/package/dhcp/S80dhcp-server b/package/dhcp/S80dhcp-server
index dc9c433..1c2ff74 100755
--- a/package/dhcp/S80dhcp-server
+++ b/package/dhcp/S80dhcp-server
@@ -14,6 +14,9 @@ OPTIONS=""
CFG_FILE="/etc/default/dhcpd"
[ -r "${CFG_FILE}" ] && . "${CFG_FILE}"
+# PID files generated by the daemon
+PID_FILES="/var/run/dhcpd.pid /var/run/dhcpd6.pid"
+
# Sanity checks
test -f /usr/sbin/dhcpd || exit 0
test -f /etc/dhcp/dhcpd.conf || exit 0
@@ -28,8 +31,13 @@ case "$1" in
;;
stop)
printf "Stopping DHCP server: "
- start-stop-daemon -K -q -x /usr/sbin/dhcpd
- [ $? = 0 ] && echo "OK" || echo "FAIL"
+ if start-stop-daemon -K -q -x /usr/sbin/dhcpd; then
+ # This daemon does not remove its PID file when it exits.
+ rm -f ${PID_FILES}
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
;;
restart | force-reload)
$0 stop
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Buildroot] [PATCH v2 7/8] package/dhcp/S80dhcp-server: support IPv6 lease file
2015-10-13 9:35 [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Benoît Thébaudeau
` (4 preceding siblings ...)
2015-10-13 9:35 ` [Buildroot] [PATCH v2 6/8] package/dhcp: SysV init scripts: remove PID files after stop Benoît Thébaudeau
@ 2015-10-13 9:35 ` Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 8/8] package/dhcp: SysV init scripts: refactor using functions Benoît Thébaudeau
2015-10-14 7:21 ` [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Maxime Hadjinlian
7 siblings, 0 replies; 13+ messages in thread
From: Benoît Thébaudeau @ 2015-10-13 9:35 UTC (permalink / raw)
To: buildroot
The IPv6 lease file has a different name.
Signed-off-by: Beno?t Th?baudeau <benoit@wsystem.com>
---
Changes v1 -> v2:
- Rebase.
---
package/dhcp/S80dhcp-server | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/package/dhcp/S80dhcp-server b/package/dhcp/S80dhcp-server
index 1c2ff74..b6f76ee 100755
--- a/package/dhcp/S80dhcp-server
+++ b/package/dhcp/S80dhcp-server
@@ -25,7 +25,10 @@ case "$1" in
start)
printf "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
+ for lease_file in /var/lib/dhcp/dhcpd.leases \
+ /var/lib/dhcp/dhcpd6.leases; do
+ test -f "${lease_file}" || touch "${lease_file}"
+ done
start-stop-daemon -S -q -x /usr/sbin/dhcpd -- -q $OPTIONS $INTERFACES
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Buildroot] [PATCH v2 8/8] package/dhcp: SysV init scripts: refactor using functions
2015-10-13 9:35 [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Benoît Thébaudeau
` (5 preceding siblings ...)
2015-10-13 9:35 ` [Buildroot] [PATCH v2 7/8] package/dhcp/S80dhcp-server: support IPv6 lease file Benoît Thébaudeau
@ 2015-10-13 9:35 ` Benoît Thébaudeau
2015-10-14 7:21 ` [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Maxime Hadjinlian
7 siblings, 0 replies; 13+ messages in thread
From: Benoît Thébaudeau @ 2015-10-13 9:35 UTC (permalink / raw)
To: buildroot
Refactor these scripts using start()/stop() functions rather than having
these scripts invoke themselves.
By the way, clean up these scripts.
Signed-off-by: Beno?t Th?baudeau <benoit@wsystem.com>
---
Changes v1 -> v2:
- Rebase.
- Use 'printf' instead of 'echo -n' following
0f75b2635ee564fbbdb9ea631cf39fa8731d6d6c.
---
package/dhcp/S80dhcp-relay | 63 +++++++++++++++++++++-----------------
package/dhcp/S80dhcp-server | 74 +++++++++++++++++++++++++--------------------
2 files changed, 76 insertions(+), 61 deletions(-)
diff --git a/package/dhcp/S80dhcp-relay b/package/dhcp/S80dhcp-relay
index 9b8d65f..b48f72c 100755
--- a/package/dhcp/S80dhcp-relay
+++ b/package/dhcp/S80dhcp-relay
@@ -1,61 +1,68 @@
#!/bin/sh
-#
-# $Id: dhcp3-relay,v 1.1 2004/04/16 15:41:08 ml Exp $
-#
+
+NAME="dhcrelay"
+DESC="DHCP relay"
+DAEMON="/usr/sbin/${NAME}"
+
+# On what interfaces should the DHCP relay serve DHCP requests?
+INTERFACES=""
# What servers should the DHCP relay forward requests to?
-# e.g: SERVERS="192.168.0.1"
+# E.g: SERVERS="192.168.0.1"
SERVERS=""
-# On what interfaces should the DHCP relay (dhrelay) serve DHCP requests?
-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"
+CFG_FILE="/etc/default/${NAME}"
[ -r "${CFG_FILE}" ] && . "${CFG_FILE}"
# PID files generated by the daemon
-PID_FILES="/var/run/dhcrelay.pid /var/run/dhcrelay6.pid"
+PID_FILES="/var/run/${NAME}.pid /var/run/${NAME}6.pid"
# Sanity checks
-test -f /usr/sbin/dhcrelay || exit 0
+test -f "${DAEMON}" || exit 0
test -n "$INTERFACES" || exit 0
test -n "$SERVERS" || exit 0
-# Build command line for interfaces (will be passed to dhrelay below.)
+# Build command line for interfaces (will be passed to dhcrelay below).
IFCMD=""
for I in $INTERFACES; do
IFCMD=${IFCMD}"-i "${I}" "
done
-DHCRELAYPID=/var/run/dhcrelay.pid
+start()
+{
+ printf "Starting ${DESC}: "
+ start-stop-daemon -S -q -x "${DAEMON}" -- -q $OPTIONS $IFCMD $SERVERS &&
+ echo "OK" || echo "FAIL"
+}
+
+stop()
+{
+ printf "Stopping ${DESC}: "
+ if start-stop-daemon -K -q -x "${DAEMON}"; then
+ # This daemon does not remove its PID file when it exits.
+ rm -f ${PID_FILES}
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+}
case "$1" in
start)
- printf "Starting DHCP relay: "
- start-stop-daemon -S -q -x /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS
- [ $? = 0 ] && echo "OK" || echo "FAIL"
+ start
;;
stop)
- printf "Stopping DHCP relay: "
- if start-stop-daemon -K -q -x /usr/sbin/dhcrelay; then
- # This daemon does not remove its PID file when it exits.
- rm -f ${PID_FILES}
- echo "OK"
- else
- echo "FAIL"
- fi
+ stop
;;
- restart | force-reload)
- $0 stop
- $0 start
+ restart|force-reload)
+ stop
+ start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}"
exit 1
esac
-
-exit 0
diff --git a/package/dhcp/S80dhcp-server b/package/dhcp/S80dhcp-server
index b6f76ee..607f1ca 100755
--- a/package/dhcp/S80dhcp-server
+++ b/package/dhcp/S80dhcp-server
@@ -1,57 +1,65 @@
#!/bin/sh
-#
-# $Id: dhcp3-server.init.d,v 1.4 2003/07/13 19:12:41 mdz Exp $
-#
-# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
-# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
+NAME="dhcpd"
+DESC="DHCP server"
+DAEMON="/usr/sbin/${NAME}"
+DAEMON_CONF="/etc/dhcp/${NAME}.conf"
+DAEMON_LIB_DIR="/var/lib/dhcp"
+LEASE_FILES="${DAEMON_LIB_DIR}/${NAME}.leases ${DAEMON_LIB_DIR}/${NAME}6.leases"
+
+# On what interfaces should the DHCP server serve DHCP requests?
+# 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"
+CFG_FILE="/etc/default/${NAME}"
[ -r "${CFG_FILE}" ] && . "${CFG_FILE}"
# PID files generated by the daemon
-PID_FILES="/var/run/dhcpd.pid /var/run/dhcpd6.pid"
+PID_FILES="/var/run/${NAME}.pid /var/run/${NAME}6.pid"
# Sanity checks
-test -f /usr/sbin/dhcpd || exit 0
-test -f /etc/dhcp/dhcpd.conf || exit 0
+test -f "${DAEMON}" || exit 0
+test -f "${DAEMON_CONF}" || exit 0
+
+start()
+{
+ printf "Starting ${DESC}: "
+ test -d "${DAEMON_LIB_DIR}" || mkdir -p "${DAEMON_LIB_DIR}"
+ for lease_file in ${LEASE_FILES}; do
+ test -f "${lease_file}" || touch "${lease_file}"
+ done
+ start-stop-daemon -S -q -x "${DAEMON}" -- -q $OPTIONS $INTERFACES &&
+ echo "OK" || echo "FAIL"
+}
+
+stop()
+{
+ printf "Stopping ${DESC}: "
+ if start-stop-daemon -K -q -x "${DAEMON}"; then
+ # This daemon does not remove its PID file when it exits.
+ rm -f ${PID_FILES}
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+}
case "$1" in
start)
- printf "Starting DHCP server: "
- test -d /var/lib/dhcp/ || mkdir -p /var/lib/dhcp/
- for lease_file in /var/lib/dhcp/dhcpd.leases \
- /var/lib/dhcp/dhcpd6.leases; do
- test -f "${lease_file}" || touch "${lease_file}"
- done
- start-stop-daemon -S -q -x /usr/sbin/dhcpd -- -q $OPTIONS $INTERFACES
- [ $? = 0 ] && echo "OK" || echo "FAIL"
+ start
;;
stop)
- printf "Stopping DHCP server: "
- if start-stop-daemon -K -q -x /usr/sbin/dhcpd; then
- # This daemon does not remove its PID file when it exits.
- rm -f ${PID_FILES}
- echo "OK"
- else
- echo "FAIL"
- fi
+ stop
;;
- restart | force-reload)
- $0 stop
- $0 start
- if [ "$?" != "0" ]; then
- exit 1
- fi
+ restart|force-reload)
+ stop
+ start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}"
exit 1
esac
-
-exit 0
--
2.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing
2015-10-13 9:35 [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Benoît Thébaudeau
` (6 preceding siblings ...)
2015-10-13 9:35 ` [Buildroot] [PATCH v2 8/8] package/dhcp: SysV init scripts: refactor using functions Benoît Thébaudeau
@ 2015-10-14 7:21 ` Maxime Hadjinlian
2015-10-14 9:17 ` Benoît Thébaudeau
7 siblings, 1 reply; 13+ messages in thread
From: Maxime Hadjinlian @ 2015-10-14 7:21 UTC (permalink / raw)
To: buildroot
Hi Benoit,
On Tue, Oct 13, 2015 at 11:35 AM, Beno?t Th?baudeau <benoit@wsystem.com>
wrote:
> 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.
>
> Signed-off-by: Beno?t Th?baudeau <benoit@wsystem.com>
>
>
Thanks a lot for your work, I am afraid I am going to add to your work and
maybe be a bit of a kill joy:
What about systemd ?
There's already a service file in the dhcp package, so any changes made to
the init scripts should also be made to the .service to keep the whole
package coherent.
If you need any help/tips, do ask.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151014/d405aafd/attachment.html>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing
2015-10-14 7:21 ` [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Maxime Hadjinlian
@ 2015-10-14 9:17 ` Benoît Thébaudeau
2015-10-14 9:38 ` Thomas Petazzoni
2015-10-14 11:44 ` Maxime Hadjinlian
0 siblings, 2 replies; 13+ messages in thread
From: Benoît Thébaudeau @ 2015-10-14 9:17 UTC (permalink / raw)
To: buildroot
Hi Maxime,
On 14/10/2015 09:21, Maxime Hadjinlian wrote:
> On Tue, Oct 13, 2015 at 11:35 AM, Beno?t Th?baudeau <benoit at wsystem.com <mailto:benoit@wsystem.com>> wrote:
>
> 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.
>
> Signed-off-by: Beno?t Th?baudeau <benoit at wsystem.com <mailto:benoit@wsystem.com>>
>
>
> Thanks a lot for your work, I am afraid I am going to add to your work and maybe be a bit of a kill joy:
>
> What about systemd ?
>
> There's already a service file in the dhcp package, so any changes made to the init scripts should also be made to the .service to keep the whole package coherent.
>
> If you need any help/tips, do ask.
I don't have any experience with systemd. I see the basics from the online
documentation.
In order to switch an existing SysV + BusyBox defconfig to systemd, is there
anything else to tweak than setting the init system to systemd in the
configuration?
Looking at the files, most of this series seems to already be fine with systemd.
The SysV init scripts have not been kept consistent when systemd was added. But
there are a few things to do for systemd though.
For 1/8, would it be OK to change "EnvironmentFile=/etc/default/dhcpd.conf" to
"EnvironmentFile=/etc/default/dhcpd" for systemd in order to share the filename
with SysV? If I look into the /etc/default/ folder on my Ubuntu 15.04 (which
uses systemd), none of the files present has a .conf extension. The purpose of
these files is to set some environment variables, so they're more scripts than
configuration files.
When a change would affect both SysV and systemd, should there be a single patch
common to both, or one patch per init system?
Best regards,
Beno?t
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing
2015-10-14 9:17 ` Benoît Thébaudeau
@ 2015-10-14 9:38 ` Thomas Petazzoni
2015-10-14 11:44 ` Maxime Hadjinlian
1 sibling, 0 replies; 13+ messages in thread
From: Thomas Petazzoni @ 2015-10-14 9:38 UTC (permalink / raw)
To: buildroot
Hello Beno?t,
On Wed, 14 Oct 2015 11:17:32 +0200, Beno?t Th?baudeau wrote:
> I don't have any experience with systemd. I see the basics from the online
> documentation.
>
> In order to switch an existing SysV + BusyBox defconfig to systemd, is there
> anything else to tweak than setting the init system to systemd in the
> configuration?
>
> Looking at the files, most of this series seems to already be fine with systemd.
> The SysV init scripts have not been kept consistent when systemd was added. But
> there are a few things to do for systemd though.
>
> For 1/8, would it be OK to change "EnvironmentFile=/etc/default/dhcpd.conf" to
> "EnvironmentFile=/etc/default/dhcpd" for systemd in order to share the filename
> with SysV? If I look into the /etc/default/ folder on my Ubuntu 15.04 (which
> uses systemd), none of the files present has a .conf extension. The purpose of
> these files is to set some environment variables, so they're more scripts than
> configuration files.
>
> When a change would affect both SysV and systemd, should there be a single patch
> common to both, or one patch per init system?
Separate patches. And note that despite Maxime's question on systemd,
you are definitely not forced to add systemd support to the dhcp
package. It is fine if you do only SysV support, and someone else
interested in systemd does the systemd part.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing
2015-10-14 9:17 ` Benoît Thébaudeau
2015-10-14 9:38 ` Thomas Petazzoni
@ 2015-10-14 11:44 ` Maxime Hadjinlian
1 sibling, 0 replies; 13+ messages in thread
From: Maxime Hadjinlian @ 2015-10-14 11:44 UTC (permalink / raw)
To: buildroot
On Wed, Oct 14, 2015 at 11:17 AM, Beno?t Th?baudeau <benoit@wsystem.com>
wrote:
> Hi Maxime,
>
> On 14/10/2015 09:21, Maxime Hadjinlian wrote:
> > On Tue, Oct 13, 2015 at 11:35 AM, Beno?t Th?baudeau <benoit@wsystem.com
> <mailto:benoit@wsystem.com>> wrote:
> >
> > 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.
> >
> > Signed-off-by: Beno?t Th?baudeau <benoit@wsystem.com <mailto:
> benoit at wsystem.com>>
> >
> >
> > Thanks a lot for your work, I am afraid I am going to add to your work
> and maybe be a bit of a kill joy:
> >
> > What about systemd ?
> >
> > There's already a service file in the dhcp package, so any changes made
> to the init scripts should also be made to the .service to keep the whole
> package coherent.
> >
> > If you need any help/tips, do ask.
>
> I don't have any experience with systemd. I see the basics from the online
> documentation.
>
> In order to switch an existing SysV + BusyBox defconfig to systemd, is
> there
> anything else to tweak than setting the init system to systemd in the
> configuration?
>
That's it, that's all you gotta do.
>
> Looking at the files, most of this series seems to already be fine with
> systemd.
> The SysV init scripts have not been kept consistent when systemd was
> added. But
> there are a few things to do for systemd though.
>
> For 1/8, would it be OK to change
> "EnvironmentFile=/etc/default/dhcpd.conf" to
> "EnvironmentFile=/etc/default/dhcpd" for systemd in order to share the
> filename
> with SysV? If I look into the /etc/default/ folder on my Ubuntu 15.04
> (which
> uses systemd), none of the files present has a .conf extension. The
> purpose of
> these files is to set some environment variables, so they're more scripts
> than
> configuration files.
>
Yep that's a good idea.
>
> When a change would affect both SysV and systemd, should there be a single
> patch
> common to both, or one patch per init system?
>
Separate patch would be better I think.
>
> Best regards,
> Beno?t
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151014/7007b7b7/attachment.html>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-10-14 11:44 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-13 9:35 [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 2/8] package/dhcp/S80dhcp-server: support extra options Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 3/8] package/dhcp/S80dhcp-server: allow empty INTERFACES Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 4/8] package/dhcp: fix SysV init scripts output text Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 5/8] package/dhcp: remove sleep from SysV init scripts restart Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 6/8] package/dhcp: SysV init scripts: remove PID files after stop Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 7/8] package/dhcp/S80dhcp-server: support IPv6 lease file Benoît Thébaudeau
2015-10-13 9:35 ` [Buildroot] [PATCH v2 8/8] package/dhcp: SysV init scripts: refactor using functions Benoît Thébaudeau
2015-10-14 7:21 ` [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Maxime Hadjinlian
2015-10-14 9:17 ` Benoît Thébaudeau
2015-10-14 9:38 ` Thomas Petazzoni
2015-10-14 11:44 ` Maxime Hadjinlian
-- strict thread matches above, loose matches on Subject: below --
2015-08-21 16:45 [Buildroot] [PATCH v2 0/8] package/dhcp: rework the SysV init scripts Benoît Thébaudeau
2015-08-21 16:45 ` [Buildroot] [PATCH v2 1/8] package/dhcp: fix SysV init scripts option passing Benoît Thébaudeau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox