From 415856bdd4f48ab4f2732996f0bae58595092bbe Mon Sep 17 00:00:00 2001 From: Parabola Date: Tue, 5 Apr 2011 14:26:38 +0000 Subject: Tue Apr 5 14:26:38 UTC 2011 --- extra/ifplugd/PKGBUILD | 47 ++++++++++++++++ extra/ifplugd/ifdown.01-route.sh | 3 + extra/ifplugd/ifplugd | 89 ++++++++++++++++++++++++++++++ extra/ifplugd/ifplugd-0.28-interface.patch | 13 +++++ extra/ifplugd/ifplugd.action | 29 ++++++++++ extra/ifplugd/ifup.01-route.sh | 5 ++ extra/ifplugd/ifup.02-ntpdate.sh | 2 + 7 files changed, 188 insertions(+) create mode 100644 extra/ifplugd/PKGBUILD create mode 100755 extra/ifplugd/ifdown.01-route.sh create mode 100644 extra/ifplugd/ifplugd create mode 100644 extra/ifplugd/ifplugd-0.28-interface.patch create mode 100644 extra/ifplugd/ifplugd.action create mode 100755 extra/ifplugd/ifup.01-route.sh create mode 100755 extra/ifplugd/ifup.02-ntpdate.sh (limited to 'extra/ifplugd') diff --git a/extra/ifplugd/PKGBUILD b/extra/ifplugd/PKGBUILD new file mode 100644 index 000000000..e3162ac9a --- /dev/null +++ b/extra/ifplugd/PKGBUILD @@ -0,0 +1,47 @@ +# $Id: PKGBUILD 70831 2010-03-01 22:51:10Z dgriffiths $ +# Contributor: Manolis Tzanidakis +# Contributor: kevin +# Maintainer: Thayer Williams + +pkgname=ifplugd +pkgver=0.28 +pkgrel=7 +pkgdesc="A daemon which brings up/down network interfaces upon cable insertion/removal." +arch=('i686' 'x86_64') +url="http://0pointer.de/lennart/projects/ifplugd" +license=('GPL2') +depends=('libdaemon' 'bash') +backup=('etc/ifplugd/ifplugd.conf' 'etc/ifplugd/ifplugd.action') +options=('!makeflags') +source=($url/${pkgname}-${pkgver}.tar.gz 'ifplugd' 'ifplugd.action' 'ifplugd-0.28-interface.patch' 'ifdown.01-route.sh' 'ifup.01-route.sh' 'ifup.02-ntpdate.sh') +md5sums=('df6f4bab52f46ffd6eb1f5912d4ccee3' '70d66121ae5163348855236951e069a2'\ + 'e91a3d77d707ae79fbc10146848032dc' '54eb22844b5aeed161c0b80aa9008570'\ + 'd6ce6c7bd481a0b3944c944c5b277c0b' 'c35f0a637911b747f8dc3bd3c6156a1b'\ + 'f8690ee18a5ca72555585ee96826c2cf') + +build() { + cd ${srcdir}/${pkgname}-${pkgver} + patch -p0 < ../ifplugd-0.28-interface.patch + ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc \ + --with-initdir=/etc/rc.d --disable-xmltoman --disable-subversion --disable-lynx + /usr/bin/make || return 1 + /usr/bin/make DESTDIR=${pkgdir} install + + # replace INTERFACES with NET_IFS since AL already uses it in /etc/rc.conf + /bin/sed -i "s:INTERFACES:NET_IFS:g" \ + ${pkgdir}/etc/ifplugd/ifplugd.conf || return 1 + + # replace the default init script & action files with ours. + #/bin/rm -rf $/pkgdir/etc/init.d + /bin/install -D -m755 ${srcdir}/ifplugd ${pkgdir}/etc/rc.d/ifplugd || return 1 + /bin/install -D -m755 ${srcdir}/ifplugd.action \ + ${pkgdir}/etc/ifplugd/ifplugd.action || return 1 + + /bin/install -Dm755 ${srcdir}/ifdown.01-route.sh \ + ${pkgdir}/etc/ifplugd/ifdown.d/01-route.sh || return 1 + /bin/install -Dm755 ${srcdir}/ifup.01-route.sh \ + ${pkgdir}/etc/ifplugd/ifup.d/01-route.sh || return 1 + /bin/install -Dm755 ${srcdir}/ifup.02-ntpdate.sh \ + ${pkgdir}/etc/ifplugd/ifup.d/02-ntpdate.sh || return 1 +} + diff --git a/extra/ifplugd/ifdown.01-route.sh b/extra/ifplugd/ifdown.01-route.sh new file mode 100755 index 000000000..cfa0e0069 --- /dev/null +++ b/extra/ifplugd/ifdown.01-route.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# same as up... +/sbin/route del $1 \ No newline at end of file diff --git a/extra/ifplugd/ifplugd b/extra/ifplugd/ifplugd new file mode 100644 index 000000000..44019d0ee --- /dev/null +++ b/extra/ifplugd/ifplugd @@ -0,0 +1,89 @@ +#!/bin/bash +# +# ifplugd daemon script for Arch Linux + +. /etc/rc.conf +. /etc/rc.d/functions + +# env vars +NAME=ifplugd +CFG=/etc/ifplugd/ifplugd.conf +IFPLUGD=/usr/sbin/ifplugd +PID=`pidof -o %PPID $IFPLUGD` + +# source configuration file +[ -f $CFG ] && . $CFG + +# discover interfaces to monitor +# (replacing INTERFACES with NET_IFS, since AL +# already uses it in /etc/rc.conf) +[ -z "$NET_IFS" ] && + NET_IFS=$(sed -ne 's/.*\<\(eth[0-9]*\):.*/\1/p' /proc/net/dev) + +case "$1" in + start) + stat_busy "Starting $NAME" + [ -z "$PID" ] && ( for IF in $NET_IFS ; do + A="`eval echo \$\{ARGS_${IF}\}`" + [ -z "$A" ] && A="$ARGS" + $IFPLUGD -i $IF $A + echo -n " $IF" + done ) + if [ $? -gt 0 ]; then + stat_fail + else + add_daemon $NAME + stat_done + fi + ;; + stop) + stat_busy "Stopping $NAME" + [ ! -z "$PID" ] && ( for IF in $NET_IFS ; do + $IFPLUGD -k -i $IF + echo -n " $IF" + done ) + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon $NAME + stat_done + fi + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + status) + for IF in $NET_IFS; do + $IFPLUGD -c -i $IF + done + ;; + suspend) + stat_busy "Suspending $NAME" + for IF in $NET_IFS; do + $IFPLUGD -S -i $IF + echo -n " $IF" + done + if [ $? -gt 0 ]; then + stat_fail + else + stat_done + fi + ;; + resume) + stat_busy "Resuming $NAME" + for IF in $NET_IFS; do + $IFPLUGD -R -i $IF + echo -n " $IF" + done + if [ $? -gt 0 ]; then + stat_fail + else + stat_done + fi + ;; + *) + echo "usage: $0 {start|stop|restart|status|suspend|resume}" +esac +exit 0 diff --git a/extra/ifplugd/ifplugd-0.28-interface.patch b/extra/ifplugd/ifplugd-0.28-interface.patch new file mode 100644 index 000000000..9c2de464b --- /dev/null +++ b/extra/ifplugd/ifplugd-0.28-interface.patch @@ -0,0 +1,13 @@ +--- src/interface.c 2004/12/19 00:08:01 114 ++++ src/interface.c 2006/03/07 13:15:11 133 +@@ -22,9 +22,9 @@ + #include + #endif + ++#include + #include + #include +-#include + #include + #include + #include diff --git a/extra/ifplugd/ifplugd.action b/extra/ifplugd/ifplugd.action new file mode 100644 index 000000000..23b74c60d --- /dev/null +++ b/extra/ifplugd/ifplugd.action @@ -0,0 +1,29 @@ +#!/bin/sh +# +# ifplugd.action script for Arch Linux + +. /etc/rc.conf +. /etc/rc.d/functions + +plugscript(){ #argumets are ifup|ifdown, interface_name + for script in /etc/ifplugd/$1.d/*.sh; do + [ -x $script ] && $script $2 + done + return 0 +} + +case "$2" in + up) + /etc/rc.d/network ifup $1 + plugscript ifup $1 + ;; + down) + plugscript ifdown $1 + /etc/rc.d/network ifdown $1 + ;; + *) + echo "Wrong arguments" > /dev/stderr + ;; +esac + +exit 1 diff --git a/extra/ifplugd/ifup.01-route.sh b/extra/ifplugd/ifup.01-route.sh new file mode 100755 index 000000000..6be07208d --- /dev/null +++ b/extra/ifplugd/ifup.01-route.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# ugly way to load up gateway, since +# al's net configuration doesn't associate +# gateways with specific interfaces. +/sbin/route add $gateway diff --git a/extra/ifplugd/ifup.02-ntpdate.sh b/extra/ifplugd/ifup.02-ntpdate.sh new file mode 100755 index 000000000..4e53daff9 --- /dev/null +++ b/extra/ifplugd/ifup.02-ntpdate.sh @@ -0,0 +1,2 @@ +#!/bin/sh +ntpdate ru.pool.ntp.org | logger -- cgit v1.2.3-54-g00ecf