dhcpcd: add SysV start-up script
authorMarkus Mayer <mmayer@broadcom.com>
Tue, 31 Oct 2017 22:36:58 +0000 (15:36 -0700)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Thu, 2 Nov 2017 22:03:30 +0000 (23:03 +0100)
Add System V start-up script for dhcpcd that is run after the network
has been brought up.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/dhcpcd/S41dhcpcd [new file with mode: 0755]
package/dhcpcd/dhcpcd.mk

diff --git a/package/dhcpcd/S41dhcpcd b/package/dhcpcd/S41dhcpcd
new file mode 100755 (executable)
index 0000000..a2e87ca
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# Start/stop dhcpcd
+#
+
+DAEMON=/sbin/dhcpcd
+CONFIG=/etc/dhcpcd.conf
+PIDFILE=/var/run/dhcpcd.pid
+
+[ -x $DAEMON ] || exit 0
+[ -f $CONFIG ] || exit 0
+
+case "$1" in
+  start)
+       echo "Starting dhcpcd..."
+       start-stop-daemon -S -x "$DAEMON" -p "$PIDFILE" -- -f "$CONFIG"
+       ;;
+  stop)
+       echo "Stopping dhcpcd..."
+       start-stop-daemon -K -x "$DAEMON" -p "$PIDFILE" -o
+       ;;
+  reload|force-reload)
+       echo "Reloading dhcpcd configuration..."
+       "$DAEMON" -s reload
+       ;;
+  restart)
+       "$0" stop
+       sleep 1 # Prevent race condition: ensure dhcpcd stops before start.
+       "$0" start
+       ;;
+  *)
+       echo "Usage: $0 {start|stop|restart|reload|force-reload}"
+       exit 1
+esac
index 1d29cda2ade8982447049a219d8d8b24e8a0e2ef..cf1da4f1470151522ab75fd151c9140776a5f4ca 100644 (file)
@@ -36,6 +36,11 @@ define DHCPCD_INSTALL_TARGET_CMDS
        $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) install DESTDIR=$(TARGET_DIR)
 endef
 
+define DHCPCD_INSTALL_INIT_SYSV
+       $(INSTALL) -m 755 -D package/dhcpcd/S41dhcpcd \
+               $(TARGET_DIR)/etc/init.d/S41dhcpcd
+endef
+
 # NOTE: Even though this package has a configure script, it is not generated
 # using the autotools, so we have to use the generic package infrastructure.