diff mbox

[1/5] busybox: Disable default ifplugd, and add initscripts for it

Message ID 0c562a0ed9774dec87bafb449c67ca51ac2deb2c.1388663997.git.christian.braunersorensen@prevas.dk
State Superseded
Delegated to: Esben Haabendal
Headers show

Commit Message

christian.braunersorensen@prevas.dk Jan. 2, 2014, 12:01 p.m. UTC
From: Christian Sørensen <christian.braunersorensen@prevas.dk>

---
 recipes/busybox/busybox-1.21.0/defconfig     |  2 +-
 recipes/busybox/busybox-configure.inc        |  9 +++++++
 recipes/busybox/busybox-install.inc          |  7 +++++
 recipes/busybox/busybox.inc                  |  3 +++
 recipes/busybox/files/busybox-ifplugd        | 38 ++++++++++++++++++++++++++++
 recipes/busybox/files/busybox-ifplugd.action | 30 ++++++++++++++++++++++
 recipes/busybox/files/busybox-ifplugd.conf   | 18 +++++++++++++
 7 files changed, 106 insertions(+), 1 deletion(-)
 create mode 100644 recipes/busybox/files/busybox-ifplugd
 create mode 100644 recipes/busybox/files/busybox-ifplugd.action
 create mode 100644 recipes/busybox/files/busybox-ifplugd.conf
diff mbox

Patch

diff --git a/recipes/busybox/busybox-1.21.0/defconfig b/recipes/busybox/busybox-1.21.0/defconfig
index 4bdc354..cd1bc3c 100644
--- a/recipes/busybox/busybox-1.21.0/defconfig
+++ b/recipes/busybox/busybox-1.21.0/defconfig
@@ -746,7 +746,7 @@  CONFIG_FEATURE_IFCONFIG_STATUS=y
 CONFIG_FEATURE_IFCONFIG_HW=y
 CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
 # CONFIG_IFENSLAVE is not set
-CONFIG_IFPLUGD=y
+# CONFIG_IFPLUGD is not set
 CONFIG_IFUPDOWN=y
 CONFIG_IFUPDOWN_IFSTATE_PATH="/var/run/ifstate"
 CONFIG_FEATURE_IFUPDOWN_IP=y
diff --git a/recipes/busybox/busybox-configure.inc b/recipes/busybox/busybox-configure.inc
index ad04650..3504da1 100644
--- a/recipes/busybox/busybox-configure.inc
+++ b/recipes/busybox/busybox-configure.inc
@@ -862,3 +862,12 @@  BUSYBOX_SIMPLE_USE_FLAGS += "ubimkvol:util/"
 BUSYBOX_SIMPLE_USE_FLAGS += "ubirmvol:util/"
 BUSYBOX_SIMPLE_USE_FLAGS += "ubirsvol:util/"
 BUSYBOX_SIMPLE_USE_FLAGS += "ubiupdatevol:util/"
+
+# USE flag: enable ifplugd service
+BUSYBOX_SIMPLE_USE_FLAGS += "ifplugd:service/ifplugd"
+RECIPE_FLAGS += "busybox_ifplugd_sysvinit_start busybox_ifplugd_sysvinit_stop"
+DEFAULT_USE_busybox_ifplugd_sysvinit_start = "25"
+DEFAULT_USE_busybox_ifplugd_sysvinit_stop  = "20"
+RECIPE_FLAGS += "busybox_ifplugd_splashutils_progress busybox_ifplugd_splashutils_msg"
+SPLASHUTILS_INITSCRIPTS:>USE_busybox_ifplugd += " busybox_ifplugd"
+DEFAULT_USE_busybox_ifplugd_splashutils_msg = "\"Starting Busybox ifplugd\""
diff --git a/recipes/busybox/busybox-install.inc b/recipes/busybox/busybox-install.inc
index de264b5..574c59d 100644
--- a/recipes/busybox/busybox-install.inc
+++ b/recipes/busybox/busybox-install.inc
@@ -134,6 +134,13 @@  do_install () {
 	if grep "CONFIG_HTTPD=y" ${S}/.config; then
 		sysvinit_install_script ${SRCDIR}/busybox-httpd
 	fi
+
+	if grep "CONFIG_IFPLUGD=y" ${S}/.config; then
+		sysvinit_install_script ${SRCDIR}/busybox-ifplugd
+		install -d ${D}${sysconfdir}/ifplugd
+		install -m 0755 ${SRCDIR}/busybox-ifplugd.action ${D}${sysconfdir}/ifplugd/ifplugd.action
+		install -m 0644 ${SRCDIR}/busybox-ifplugd.conf ${D}${sysconfdir}/ifplugd/ifplugd.conf
+	fi
 }
 
 do_install[postfuncs] += "${BUSYBOX_INSTALL_POSTFUNCS}"
diff --git a/recipes/busybox/busybox.inc b/recipes/busybox/busybox.inc
index 92dc329..540e478 100644
--- a/recipes/busybox/busybox.inc
+++ b/recipes/busybox/busybox.inc
@@ -36,6 +36,9 @@  SRC_URI += "\
 	file://busybox-ntpd \
 	file://busybox-httpd \
 	file://default.script \
+	file://busybox-ifplugd \
+	file://busybox-ifplugd.action \
+	file://busybox-ifplugd.conf \
 "
 
 PACKAGES:<USE_busybox_udhcpc = "${PN}-udhcpc-scripts "
diff --git a/recipes/busybox/files/busybox-ifplugd b/recipes/busybox/files/busybox-ifplugd
new file mode 100644
index 0000000..6fd6230
--- /dev/null
+++ b/recipes/busybox/files/busybox-ifplugd
@@ -0,0 +1,38 @@ 
+#!/bin/sh
+
+CFG=/etc/ifplugd/ifplugd.conf
+
+IFPLUGD=/usr/sbin/ifplugd
+test -x $IFPLUGD || exit 0
+
+[ -f $CFG ] && . $CFG
+
+[ "x$INTERFACES" = "xauto" ] && INTERFACES="`cat /proc/net/dev | awk '{ print $1 }' | egrep '^(eth|wlan)' | cut -d
+: -f1`"
+
+# See how we were called.
+case "$1" in
+  start)
+        echo -n "Starting ifplugd: "
+        for IF in $INTERFACES ; do
+            A="`eval echo \$\{ARGS_${IF}\}`"
+            [ -z "$A" ] && A="$ARGS"
+            $IFPLUGD -i $IF $A
+            echo -n " $IF"
+        done
+        echo
+        ;;
+  stop)
+        echo -n "Shutting down ifplugd: "
+        killall ifplugd
+        ;;
+  restart)
+        $0 stop $INTERFACES
+        $0 start $INTERFACES
+        ;;
+  *)
+        echo "Usage: $0 {start|stop|restart}"
+        exit 1
+esac
+
+exit 0
diff --git a/recipes/busybox/files/busybox-ifplugd.action b/recipes/busybox/files/busybox-ifplugd.action
new file mode 100644
index 0000000..39c7c58
--- /dev/null
+++ b/recipes/busybox/files/busybox-ifplugd.action
@@ -0,0 +1,30 @@ 
+#!/bin/sh
+# $Id: ifplugd.action 99 2004-02-08 20:17:59Z lennart $
+
+# This file is part of ifplugd.
+#
+# ifplugd is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# ifplugd is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with ifplugd; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+
+set -e
+
+if [ -z "$1" ] || [ -z "$2" ] ; then
+    echo "Wrong arguments" > /dev/stderr
+    exit 1
+fi
+
+[ "$2" = "up" ] && exec /sbin/ifup $1
+[ "$2" = "down" ] && exec /sbin/ifdown $1
+
+exit 1
diff --git a/recipes/busybox/files/busybox-ifplugd.conf b/recipes/busybox/files/busybox-ifplugd.conf
new file mode 100644
index 0000000..d6c977f
--- /dev/null
+++ b/recipes/busybox/files/busybox-ifplugd.conf
@@ -0,0 +1,18 @@ 
+# -*-sh-*-
+# ifplugd configuration file
+
+# Please note that this is a bourne shell fragment sourced by the
+# init script of ifplugd.
+
+# Specify the interfaces to control here, separated by spaces.
+# Ifplugd processes will be started for each of these interfaces
+INTERFACES="eth0"
+
+# Additional parameters for ifplugd.
+# (Run "ifplugd -h" for further information.)
+ARGS="-fI -u0 -d10"
+
+# Additional parameters for ifplugd for the specified interface.  Note
+# that $ARGS is ignored, when a variable like this is set for an
+# interface
+#ARGS_wlan0="-MwI -u5 -d5"