From dadd1323eb57cc605760441fed3b69614cf498b7 Mon Sep 17 00:00:00 2001 From: John Klug Date: Tue, 3 Oct 2017 16:00:14 -0500 Subject: Add ifplugd feature to mlinux --- recipes-core/busybox/busybox_%.bbappend | 48 +++++++++++++++++++-- recipes-core/busybox/files/defconfig | 2 +- recipes-core/busybox/files/eth0.conf | 3 ++ recipes-core/busybox/files/eth1.conf.example | 2 + recipes-core/busybox/files/ifplugd.action | 30 ++++++++++++++ recipes-core/busybox/files/ifplugd.default | 3 ++ recipes-core/busybox/files/ifplugd.init | 62 ++++++++++++++++++++++++++++ 7 files changed, 145 insertions(+), 5 deletions(-) create mode 100755 recipes-core/busybox/files/eth0.conf create mode 100755 recipes-core/busybox/files/eth1.conf.example create mode 100755 recipes-core/busybox/files/ifplugd.action create mode 100644 recipes-core/busybox/files/ifplugd.default create mode 100755 recipes-core/busybox/files/ifplugd.init (limited to 'recipes-core/busybox') diff --git a/recipes-core/busybox/busybox_%.bbappend b/recipes-core/busybox/busybox_%.bbappend index 4c6e752..f4311df 100644 --- a/recipes-core/busybox/busybox_%.bbappend +++ b/recipes-core/busybox/busybox_%.bbappend @@ -1,10 +1,50 @@ -PR .= ".mlinux1" - +PR .= ".mlinux2" FILESEXTRAPATHS_prepend := ":${THISDIR}/files:" -SRC_URI += "file://udhcpd.conf.example" +SRC_URI += "file://udhcpd.conf.example \ + file://ifplugd.action \ + file://ifplugd.default \ + file://ifplugd.init \ + file://eth0.conf \ + file://eth1.conf.example \ +" do_install_append () { - install -m 600 ${WORKDIR}/udhcpd.conf.example ${D}${sysconfdir}/udhcpd.conf.example + install -m 644 ${WORKDIR}/udhcpd.conf.example ${D}${sysconfdir}/udhcpd.conf.example install -m 600 ${WORKDIR}/udhcpd.conf.example ${D}${sysconfdir}/udhcpd.conf + install -d -m 755 ${D}${sysconfdir}/init.d + install -d -m 755 ${D}${sysconfdir}/ifplugd + install -d -m 755 ${D}${sysconfdir}/default + install -m 755 ${WORKDIR}/ifplugd.init ${D}${sysconfdir}/init.d/ifplugd + install -m 755 ${WORKDIR}/ifplugd.default ${D}${sysconfdir}/default/ifplugd + install -m 755 ${WORKDIR}/ifplugd.action ${D}${sysconfdir}/ifplugd + install -m 755 ${WORKDIR}/eth0.conf ${D}${sysconfdir}/ifplugd + install -m 644 ${WORKDIR}/eth1.conf.example ${D}${sysconfdir}/ifplugd } + +RDEPENDS_${PN}-ifplugd += "bash" +# PACKAGES =+ "${PN}-ifplugd" +inherit update-rc.d +INITSCRIPT_PACKAGES += "${PN}-ifplugd" +INITSCRIPT_NAME_${PN}-ifplugd = "ifplugd" +INITSCRIPT_PARAMS_${PN}-ifplugd = "defaults 3" + +FILES_${PN}-ifplugd = "${sysconfdir}/ifplugd/eth0.conf \ + ${sysconfdir}/ifplugd/eth1.conf.example \ + ${sysconfdir}/ifplugd/ifplugd.action \ + ${sysconfdir}/default/ifplugd \ + ${sysconfdir}/init.d/ifplugd \ + " + +FILES_${PN}-udhcpc =+ "${sysconfidir}/udhcpd.conf \ + ${sysconfidir}/udhcpd.conf.example \ + " + + +CONFFILES_${PN}-ifplugd = "${sysconfdir}/ifplugd/eth0.conf \ + ${sysconfdir}/ifplugd/ifplugd.action \ + ${sysconfdir}/default/ifplugd \ + ${sysconfidir}/udhcpd.conf \ + " + +CONFFILES_${PN}-udhcpc =+ "${sysconfidir}/udhcpd.conf" \ No newline at end of file diff --git a/recipes-core/busybox/files/defconfig b/recipes-core/busybox/files/defconfig index aa1e514..a24c108 100644 --- a/recipes-core/busybox/files/defconfig +++ b/recipes-core/busybox/files/defconfig @@ -772,7 +772,7 @@ CONFIG_FEATURE_IFCONFIG_STATUS=y CONFIG_FEATURE_IFCONFIG_HW=y # CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS is not set # CONFIG_IFENSLAVE is not set -# CONFIG_IFPLUGD is not set +CONFIG_IFPLUGD=y CONFIG_IFUPDOWN=y CONFIG_IFUPDOWN_IFSTATE_PATH="/var/run/ifstate" # CONFIG_FEATURE_IFUPDOWN_IP is not set diff --git a/recipes-core/busybox/files/eth0.conf b/recipes-core/busybox/files/eth0.conf new file mode 100755 index 0000000..4ccb2bc --- /dev/null +++ b/recipes-core/busybox/files/eth0.conf @@ -0,0 +1,3 @@ +INTERFACE="eth0" +# An arbitrary script may be specified: +ARGS="-fI -i ${INTERFACE} -u 0 -d 10 -r /etc/ifplugd/ifplugd.action" diff --git a/recipes-core/busybox/files/eth1.conf.example b/recipes-core/busybox/files/eth1.conf.example new file mode 100755 index 0000000..eb2337f --- /dev/null +++ b/recipes-core/busybox/files/eth1.conf.example @@ -0,0 +1,2 @@ +INTERFACE="eth1" +ARGS="-fI -i ${INTERFACE} -u 0 -d 10 -r /etc/ifplugd/ifplugd.action" diff --git a/recipes-core/busybox/files/ifplugd.action b/recipes-core/busybox/files/ifplugd.action new file mode 100755 index 0000000..e7184c7 --- /dev/null +++ b/recipes-core/busybox/files/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 0 diff --git a/recipes-core/busybox/files/ifplugd.default b/recipes-core/busybox/files/ifplugd.default new file mode 100644 index 0000000..a19632e --- /dev/null +++ b/recipes-core/busybox/files/ifplugd.default @@ -0,0 +1,3 @@ +ENABLED="yes" +#PIDFILE="/run/ifplugd.${INTERFACE}.pid" + diff --git a/recipes-core/busybox/files/ifplugd.init b/recipes-core/busybox/files/ifplugd.init new file mode 100755 index 0000000..97d6970 --- /dev/null +++ b/recipes-core/busybox/files/ifplugd.init @@ -0,0 +1,62 @@ +#! /bin/bash +# +# ifplugd init.d script +[[ -x /usr/sbin/ifplugd ]] || exit 0 +[[ -r /etc/default/ifplugd ]] && . /etc/default/ifplugd + + +#Functions to do individual actions +startdaemon(){ + # Start the application + echo -n "Starting ifplugd: " + CONFS=($(find /etc/ifplugd -name '*.conf')) + ((i=0)) + logger -p daemon.info "Found ${#CONFS[@]} Configurations" + while ((i < ${#CONFS[@]})) ; do + unset ARGS INTERFACE + . ${CONFS[$i]} + logger -p daemon.info "Starting Interface ${INTERFACE}" + ((i++)) + /usr/sbin/start-stop-daemon -Svp /run/ifplugd.${INTERFACE}.pid -a /usr/sbin/ifplugd -- ${ARGS} + done + if ((${#CONFS[@]} == 0)) ; then + /usr/sbin/start-stop-daemon -n ifplugd -Sv -x /usr/sbin/ifplugd -- ${ARGS} + fi + echo "done" +} +stopdaemon(){ + echo -n "Stopping ifplugd: " + PIDS=($(find /run -name 'ifplugd.*.pid')) + ((i=0)) + while ((i < ${#PIDS[@]})) ; do + PF=${PIDS[$i]} + [[ $PF =~ /ifplugd\.([^.]*)\.pid ]] + IF=${BASH_REMATCH[1]} + logger -p user.info "Shutting down interface $IF" + /usr/sbin/start-stop-daemon -n ifplugd -Kqp $PF + ((i++)) + done + echo "done" +} + +case "$1" in + start) + [[ ${ENABLED} == "yes" ]] || exit 0 + startdaemon + ;; + stop) + stopdaemon + ;; + restart|force-reload) + stopdaemon + sleep 2 + startdaemon + ;; + *) + echo "Usage: /etc/init.d/ifplugd { start | stop | restart | force-reload }" >&2 + exit 1 + ;; +esac + +exit 0 + -- cgit v1.2.3