mirror of
https://github.com/SlackBuildsOrg/slackbuilds
synced 2024-09-28 15:21:00 +02:00
network/ifplugd: Added (Network Daemon).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
parent
3d9b729316
commit
7d00fa1dbe
8 changed files with 244 additions and 0 deletions
22
network/ifplugd/README
Normal file
22
network/ifplugd/README
Normal file
|
@ -0,0 +1,22 @@
|
|||
ifplugd is a Linux daemon that can monitor network interfaces
|
||||
for a change in state (i.e. up or down) then trigger custom
|
||||
actions or scripts based on the change.
|
||||
|
||||
This could be useful in a number of situations.
|
||||
For example where the network is configured manually
|
||||
(no NetworkManager etc), and you wish to reconfigure your
|
||||
network settings when an ethernet cable is connected
|
||||
and then deconfigure those same settings when the cable is
|
||||
disconnected.
|
||||
|
||||
To change which interfaces are monitored by default, and
|
||||
the general start up options, edit "/etc/ifplugd/ifplugd.conf".
|
||||
Actions can be added/changed by editing "/etc/ifplugd/ifplugd.action".
|
||||
|
||||
To make ifplugd auto start on boot.
|
||||
First run "chmod 644 /etc/rc.d/rc.ifplugd"
|
||||
Then add the following to the end of your "/etc/rc.local" file:
|
||||
|
||||
if [ -x /etc/rc.d/rc.ifplugd ]; then
|
||||
sh /etc/rc.d/rc.ifplugd start || /bin/true
|
||||
fi
|
24
network/ifplugd/doinst.sh
Normal file
24
network/ifplugd/doinst.sh
Normal file
|
@ -0,0 +1,24 @@
|
|||
config() {
|
||||
NEW="$1"
|
||||
OLD="$(dirname $NEW)/$(basename $NEW .new)"
|
||||
if [ ! -r $OLD ]; then
|
||||
mv $NEW $OLD
|
||||
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
|
||||
rm $NEW
|
||||
fi
|
||||
}
|
||||
|
||||
preserve_perms() {
|
||||
NEW="$1"
|
||||
OLD="$(dirname $NEW)/$(basename $NEW .new)"
|
||||
if [ -e $OLD ]; then
|
||||
cp -a $OLD ${NEW}.incoming
|
||||
cat $NEW > ${NEW}.incoming
|
||||
mv ${NEW}.incoming $NEW
|
||||
fi
|
||||
config $NEW
|
||||
}
|
||||
|
||||
preserve_perms etc/rc.d/rc.ifplugd.new
|
||||
config etc/ifplugd/ifplugd.conf.new
|
||||
config etc/ifplugd/ifplugd.action.new
|
13
network/ifplugd/ifplugd-0.28-interface.patch
Normal file
13
network/ifplugd/ifplugd-0.28-interface.patch
Normal file
|
@ -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 <config.h>
|
||||
#endif
|
||||
|
||||
+#include <sys/types.h>
|
||||
#include <linux/sockios.h>
|
||||
#include <linux/if_ether.h>
|
||||
-#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/if.h>
|
18
network/ifplugd/ifplugd-action-slackware.patch
Normal file
18
network/ifplugd/ifplugd-action-slackware.patch
Normal file
|
@ -0,0 +1,18 @@
|
|||
--- conf/ifplugd.action 2022-10-21 04:32:02.560985145 +1100
|
||||
+++ conf/ifplugd.action 2022-10-21 04:37:32.173998517 +1100
|
||||
@@ -24,7 +24,13 @@
|
||||
exit 1
|
||||
fi
|
||||
|
||||
-[ "$2" = "up" ] && exec /sbin/ifup $1
|
||||
-[ "$2" = "down" ] && exec /sbin/ifdown $1
|
||||
+# Place custom actions/commands/scripts below. The interface is passed
|
||||
+# through "$1", and the state of interface is passed via "$2".
|
||||
+# i.e. if [ "$1" = "eth0" ] && [ "$2" = "down" ]; then
|
||||
+
|
||||
+# This script originally used ifup and ifdown which Slackware does
|
||||
+# not include by default. i.e. -
|
||||
+#[ "$2" = "up" ] && exec /sbin/ifup $1
|
||||
+#[ "$2" = "down" ] && exec /sbin/ifdown $1
|
||||
|
||||
exit 1
|
12
network/ifplugd/ifplugd-fix-return-value.patch
Normal file
12
network/ifplugd/ifplugd-fix-return-value.patch
Normal file
|
@ -0,0 +1,12 @@
|
|||
diff -Nur ifplugd-0.28.orig/src/ifplugd.c ifplugd-0.28/src/ifplugd.c
|
||||
--- ifplugd-0.28.orig/src/ifplugd.c 2005-06-04 21:21:51.000000000 +0200
|
||||
+++ ifplugd-0.28/src/ifplugd.c 2012-08-29 21:51:53.137644163 +0200
|
||||
@@ -447,7 +447,7 @@
|
||||
goto finish;
|
||||
|
||||
if (send_retval && daemonize && wait_on_fork) {
|
||||
- char c = status == IFSTATUS_UP ? 2 : (status == IFSTATUS_DOWN ? 3 : 1);
|
||||
+ char c = status == IFSTATUS_UP ? 1 : (status == IFSTATUS_DOWN ? 2 : 3);
|
||||
daemon_retval_send(c);
|
||||
send_retval = 0;
|
||||
}
|
126
network/ifplugd/ifplugd.SlackBuild
Normal file
126
network/ifplugd/ifplugd.SlackBuild
Normal file
|
@ -0,0 +1,126 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Slackware build script for ifplugd
|
||||
|
||||
# Copyright 2022 Anj Duvnjak
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use of this script, with or without modification, is
|
||||
# permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of this script must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
cd $(dirname $0) ; CWD=$(pwd)
|
||||
|
||||
PRGNAM=ifplugd
|
||||
VERSION=${VERSION:-0.28}
|
||||
BUILD=${BUILD:-1}
|
||||
TAG=${TAG:-_SBo}
|
||||
PKGTYPE=${PKGTYPE:-tgz}
|
||||
|
||||
if [ -z "$ARCH" ]; then
|
||||
case "$( uname -m )" in
|
||||
i?86) ARCH=i586 ;;
|
||||
arm*) ARCH=arm ;;
|
||||
*) ARCH=$( uname -m ) ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
|
||||
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TMP=${TMP:-/tmp/SBo}
|
||||
PKG=$TMP/package-$PRGNAM
|
||||
OUTPUT=${OUTPUT:-/tmp}
|
||||
|
||||
if [ "$ARCH" = "i586" ]; then
|
||||
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
|
||||
LIBDIRSUFFIX=""
|
||||
elif [ "$ARCH" = "i686" ]; then
|
||||
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
|
||||
LIBDIRSUFFIX=""
|
||||
elif [ "$ARCH" = "x86_64" ]; then
|
||||
SLKCFLAGS="-O2 -fPIC"
|
||||
LIBDIRSUFFIX="64"
|
||||
else
|
||||
SLKCFLAGS="-O2"
|
||||
LIBDIRSUFFIX=""
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
rm -rf $PKG
|
||||
mkdir -p $TMP $PKG $OUTPUT
|
||||
cd $TMP
|
||||
rm -rf $PRGNAM-$VERSION
|
||||
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
|
||||
cd $PRGNAM-$VERSION
|
||||
chown -R root:root .
|
||||
find -L . \
|
||||
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
|
||||
-o -perm 511 \) -exec chmod 755 {} \; -o \
|
||||
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
|
||||
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
|
||||
|
||||
# Process patches - credits to Arch Linux for the first two
|
||||
patch -p1 < $CWD/ifplugd-fix-return-value.patch
|
||||
patch -p0 < $CWD/ifplugd-0.28-interface.patch
|
||||
patch -p0 < $CWD/ifplugd-action-slackware.patch
|
||||
|
||||
CFLAGS="$SLKCFLAGS -fcommon" \
|
||||
CXXFLAGS="$SLKCFLAGS -fcommon" \
|
||||
./configure \
|
||||
--prefix=/usr \
|
||||
--sbindir=/usr/bin \
|
||||
--mandir=/usr/man \
|
||||
--infodir=/usr/info \
|
||||
--sysconfdir=/etc \
|
||||
--localstatedir=/var \
|
||||
--disable-static \
|
||||
--with-initdir=/etc/rc.d \
|
||||
--disable-xmltoman \
|
||||
--disable-subversion \
|
||||
--disable-lynx \
|
||||
--build=$ARCH-slackware-linux
|
||||
|
||||
make
|
||||
make install DESTDIR=$PKG
|
||||
|
||||
rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la
|
||||
|
||||
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
|
||||
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
|
||||
|
||||
find $PKG/usr/man -type f -exec gzip -9 {} \;
|
||||
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
|
||||
|
||||
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
|
||||
cp -a \
|
||||
LICENSE README doc/SUPPORTED_DRIVERS \
|
||||
$PKG/usr/doc/$PRGNAM-$VERSION
|
||||
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
|
||||
|
||||
mv $PKG/etc/ifplugd/ifplugd.action $PKG/etc/ifplugd/ifplugd.action.new
|
||||
mv $PKG/etc/ifplugd/ifplugd.conf $PKG/etc/ifplugd/ifplugd.conf.new
|
||||
mv $PKG/etc/rc.d/ifplugd $PKG/etc/rc.d/rc.ifplugd.new
|
||||
|
||||
mkdir -p $PKG/install
|
||||
cat $CWD/slack-desc > $PKG/install/slack-desc
|
||||
cat $CWD/doinst.sh > $PKG/install/doinst.sh
|
||||
|
||||
cd $PKG
|
||||
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
|
10
network/ifplugd/ifplugd.info
Normal file
10
network/ifplugd/ifplugd.info
Normal file
|
@ -0,0 +1,10 @@
|
|||
PRGNAM="ifplugd"
|
||||
VERSION="0.28"
|
||||
HOMEPAGE="http://0pointer.de/lennart/projects/ifplugd"
|
||||
DOWNLOAD="http://0pointer.de/lennart/projects/ifplugd/ifplugd-0.28.tar.gz"
|
||||
MD5SUM="df6f4bab52f46ffd6eb1f5912d4ccee3"
|
||||
DOWNLOAD_x86_64=""
|
||||
MD5SUM_x86_64=""
|
||||
REQUIRES="libdaemon"
|
||||
MAINTAINER="Anj Duvnjak"
|
||||
EMAIL="alvind11@hotmail.com"
|
19
network/ifplugd/slack-desc
Normal file
19
network/ifplugd/slack-desc
Normal file
|
@ -0,0 +1,19 @@
|
|||
# HOW TO EDIT THIS FILE:
|
||||
# The "handy ruler" below makes it easier to edit a package description.
|
||||
# Line up the first '|' above the ':' following the base package name, and
|
||||
# the '|' on the right side marks the last column you can put a character in.
|
||||
# You must make exactly 11 lines for the formatting to be correct. It's also
|
||||
# customary to leave one space after the ':' except on otherwise blank lines.
|
||||
|
||||
|-----handy-ruler------------------------------------------------------|
|
||||
ifplugd: ifplugd (daemon to reconfig network iface upon connect/disconnect)
|
||||
ifplugd:
|
||||
ifplugd: ifplugd is a Linux daemon which will automatically configure your
|
||||
ifplugd: ethernet device when a cable is plugged in and automatically
|
||||
ifplugd: unconfigure it if the cable is pulled. This is useful on laptops
|
||||
ifplugd: with onboard network adapters, since it will only configure the
|
||||
ifplugd: interface when a cable is really connected.
|
||||
ifplugd:
|
||||
ifplugd: ifplugd can interface with your distributions native network
|
||||
ifplugd: configuration utilities.
|
||||
ifplugd:
|
Loading…
Reference in a new issue