Difference between revisions of "Netplug"
Forgotten1 (talk | contribs) |
|||
(17 intermediate revisions by 5 users not shown) | |||
Line 3: | Line 3: | ||
!Download Source: | !Download Source: | ||
|- | |- | ||
− | | http://www.red-bean.com/~bos/netplug/netplug- | + | | http://www.red-bean.com/~bos/netplug/netplug-{{NetPlug-Version}}.tar.bz2 |
|- | |- | ||
− | !Download Patches | + | !Download Patches: |
|- | |- | ||
− | | netplug- | + | | http://svn.cross-lfs.org/svn/repos/patches/netplug/netplug-{{NetPlug-Version}}-gcc4-1.patch |
|- | |- | ||
− | | netplug- | + | | http://svn.cross-lfs.org/svn/repos/patches/netplug/netplug-{{NetPlug-Version}}-ignore-wireless-1.patch |
|- | |- | ||
− | | netplug- | + | | http://svn.cross-lfs.org/svn/repos/patches/netplug/netplug-{{NetPlug-Version}}-remove-nest-1.patch |
|} | |} | ||
---- | ---- | ||
− | + | {{Package-Introduction|'''Netplug''' is a Linux daemon that brings up/down network interfaces in response to network cables being plugged in and out. This application is mostly useful for a laptop or computer (used for lan parties?) that is often relocated to different LANs. | |
− | |||
− | '''Netplug''' is a Linux daemon that brings up/down network interfaces in response to network cables being plugged in and out. This application is mostly useful for a laptop or computer (used for lan parties?) that is often relocated to different LANs. | ||
− | |||
− | |||
− | |||
+ | The netplugd rc script shared below replaces the clfs-bootscripts network script. If you remove the network script and symlinks in the rc#.d directories, and later decide you want them, then merely reinstall from the clfs-bootscripts.}} | ||
== Dependencies == | == Dependencies == | ||
− | |||
− | |||
− | |||
− | |||
== Configuration Information == | == Configuration Information == | ||
Line 35: | Line 27: | ||
== Non-Multilib == | == Non-Multilib == | ||
− | |||
− | |||
Modify the Makefile: | Modify the Makefile: | ||
Line 45: | Line 35: | ||
sed -i '/bk_root/,$d' Makefile | sed -i '/bk_root/,$d' Makefile | ||
− | + | Compile the package: | |
− | patch -Np0 -i ../netplug- | + | patch -Np0 -i ../netplug-{{NetPlug-Version}}-gcc4-1.patch && |
− | patch -Np1 -i ../netplug- | + | patch -Np1 -i ../netplug-{{NetPlug-Version}}-remove-nest-1.patch && |
− | patch -Np1 -i ../netplug- | + | patch -Np1 -i ../netplug-{{NetPlug-Version}}-ignore-wireless-1.patch && |
+ | make | ||
− | + | Install the package: | |
− | |||
make install | make install | ||
+ | |||
+ | === Command Explanations === | ||
+ | |||
+ | {|- | ||
+ | | '''remove...''' | ||
+ | |- | ||
+ | | '''[[ "$C...''' | ||
+ | |- | ||
+ | | '''sed -i...:''' These commands remove -O3 (if you are using another optimization) and debugging from the Makefile. | ||
+ | '''sed -i '/bk_root/,$d' Makefile:''' This removes the bitkeeper stuff, you might omit this if you are using it. | ||
== Multilib == | == Multilib == | ||
− | ''''' | + | '''''This package does not install any libraries so only one installation is needed.''''' |
=== 32Bit === | === 32Bit === | ||
− | '' | + | Modify the Makefile: |
+ | |||
+ | remove=" -ggdb3 " | ||
+ | [[ " ${CFLAGS} " == *" -O"[0-9]" "* ]] && remove="${remove}-O3 " | ||
+ | sed -i -e "s/${remove}/ /" Makefile | ||
+ | sed -i '/bk_root/,$d' Makefile | ||
+ | |||
+ | Compile the package: | ||
+ | |||
+ | patch -Np0 -i ../netplug-{{NetPlug-Version}}-gcc4-1.patch && | ||
+ | patch -Np1 -i ../netplug-{{NetPlug-Version}}-remove-nest-1.patch && | ||
+ | patch -Np1 -i ../netplug-{{NetPlug-Version}}-ignore-wireless-1.patch && | ||
+ | make CC="gcc ${BUILD32}" | ||
+ | |||
+ | Install the package: | ||
+ | |||
+ | make install | ||
=== N32 === | === N32 === | ||
− | '' | + | Modify the Makefile: |
+ | |||
+ | remove=" -ggdb3 " | ||
+ | [[ " ${CFLAGS} " == *" -O"[0-9]" "* ]] && remove="${remove}-O3 " | ||
+ | sed -i -e "s/${remove}/ /" Makefile | ||
+ | sed -i '/bk_root/,$d' Makefile | ||
+ | |||
+ | Compile the package: | ||
+ | |||
+ | patch -Np0 -i ../netplug-{{NetPlug-Version}}-gcc4-1.patch && | ||
+ | patch -Np1 -i ../netplug-{{NetPlug-Version}}-remove-nest-1.patch && | ||
+ | patch -Np1 -i ../netplug-{{NetPlug-Version}}-ignore-wireless-1.patch && | ||
+ | make CC="gcc ${BUILDN32}" | ||
+ | |||
+ | Install the package: | ||
+ | |||
+ | make install | ||
=== 64Bit === | === 64Bit === | ||
− | '' | + | Modify the Makefile: |
+ | |||
+ | remove=" -ggdb3 " | ||
+ | [[ " ${CFLAGS} " == *" -O"[0-9]" "* ]] && remove="${remove}-O3 " | ||
+ | sed -i -e "s/${remove}/ /" Makefile | ||
+ | sed -i '/bk_root/,$d' Makefile | ||
+ | |||
+ | Compile the package: | ||
+ | |||
+ | patch -Np0 -i ../netplug-{{NetPlug-Version}}-gcc4-1.patch && | ||
+ | patch -Np1 -i ../netplug-{{NetPlug-Version}}-remove-nest-1.patch && | ||
+ | patch -Np1 -i ../netplug-{{NetPlug-Version}}-ignore-wireless-1.patch && | ||
+ | make CC="gcc ${BUILD64}" | ||
+ | |||
+ | Install the package: | ||
+ | |||
+ | make install | ||
== Configuring == | == Configuring == | ||
− | Create the netplugd script: | + | The rc script below is customized for a CLFS system. Feel free to modify this |
+ | as necessary for your system. Create the netplugd script: | ||
− | cat > /etc/rc.d/init.d/netplugd << | + | cat > /etc/rc.d/init.d/netplugd << EOF |
#!/bin/sh | #!/bin/sh | ||
######################################################################## | ######################################################################## | ||
# Begin $rc_base/init.d/netplugd | # Begin $rc_base/init.d/netplugd | ||
# | # | ||
− | # Description : Netplugd- | + | # Description : Netplugd-{{NetPlug-Version}} |
# | # | ||
# Authors : Harvey Muller | # Authors : Harvey Muller | ||
# | # | ||
− | # Version : 00. | + | # Version : 00.02 |
# | # | ||
− | # Notes : | + | # Notes : Still beta |
# | # | ||
######################################################################## | ######################################################################## | ||
Line 93: | Line 142: | ||
. ${rc_functions} | . ${rc_functions} | ||
− | [ -x /sbin/netplugd ] | + | if [ ! -x /sbin/netplugd ]; then |
+ | echo "/sbin/netplugd missing, or needs to be installed ..." | ||
+ | exit 1 | ||
+ | fi | ||
+ | # Use netplugd if present, it supplies NETPLUGDARGS if needed. | ||
if [ -f /etc/sysconfig/netplugd ]; then | if [ -f /etc/sysconfig/netplugd ]; then | ||
− | + | . /etc/sysconfig/netplugd | |
+ | fi | ||
+ | |||
+ | if [ `id -u` != "0" ] && [ "$1" = "start" -o "$1" = "stop" ] ; then | ||
+ | echo "You must be root to start, stop or restart netplugd." | ||
+ | exit 1 | ||
fi | fi | ||
Line 103: | Line 161: | ||
boot_mesg "Starting network plug daemon..." | boot_mesg "Starting network plug daemon..." | ||
loadproc /sbin/netplugd ${NETPLUGDARGS} -p /var/run/netplugd.pid | loadproc /sbin/netplugd ${NETPLUGDARGS} -p /var/run/netplugd.pid | ||
− | + | RETVAL=$? | |
− | + | echo | |
− | + | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/netplugd | |
− | + | ;; | |
− | + | ||
stop) | stop) | ||
boot_mesg "Stopping network plug daemon..." | boot_mesg "Stopping network plug daemon..." | ||
killproc netplugd | killproc netplugd | ||
− | + | RETVAL=$? | |
− | + | echo | |
− | + | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/netplugd | |
− | + | ;; | |
restart|reload) | restart|reload) | ||
${0} stop | ${0} stop | ||
${0} start | ${0} start | ||
− | + | ;; | |
status) | status) | ||
statusproc netplugd | statusproc netplugd | ||
− | + | RETVAL=$? | |
− | + | ;; | |
− | + | condrestart) | |
− | + | [ -f /var/lock/subsys/netplugd ] && restart || : | |
− | + | ;; | |
*) | *) | ||
echo "Usage: ${0} {start|stop|reload|restart|status|condrestart}" | echo "Usage: ${0} {start|stop|reload|restart|status|condrestart}" | ||
exit 1 | exit 1 | ||
− | + | ;; | |
esac | esac | ||
Line 140: | Line 198: | ||
# End $rc_base/init.d/netplugd | # End $rc_base/init.d/netplugd | ||
EOF | EOF | ||
+ | |||
+ | The [[bootscripts]] network rc script is no longer necessary. You may remove the network script and symlinks with these commands: | ||
+ | |||
+ | rm -rf /etc/rc.d/init.d/network | ||
+ | rm -rf /etc/rc.d/rc*.d/{S2,K8}0network | ||
Create symlinks to netplugd script: | Create symlinks to netplugd script: | ||
Line 145: | Line 208: | ||
ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc0.d/K80netplugd | ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc0.d/K80netplugd | ||
ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc1.d/K80netplugd | ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc1.d/K80netplugd | ||
− | ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc2.d/ | + | ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc2.d/S20netplugd |
− | ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc3.d/ | + | ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc3.d/S20netplugd |
− | ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc4.d/ | + | ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc4.d/S20netplugd |
− | ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc5.d/ | + | ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc5.d/S20netplugd |
ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc6.d/K80netplugd | ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc6.d/K80netplugd | ||
Line 155: | Line 218: | ||
sed -i 's/eth\*/eth0/' /etc/netplug/netplugd.conf | sed -i 's/eth\*/eth0/' /etc/netplug/netplugd.conf | ||
− | Netplug requires the /var/lock/subsys directory be present: | + | Netplug requires the /var/lock/subsys directory be present, and the Makefile doesn't create it: |
[ -d /var/lock/subsys ] || install -d -m755 /var/lock/subsys | [ -d /var/lock/subsys ] || install -d -m755 /var/lock/subsys | ||
− | + | You could just modify the policy agent to reflect the CLFS locations, but let's make links in /sbin for ifup and ifdown: | |
ln -sf /etc/sysconfig/network-devices/ifup /sbin/ifup | ln -sf /etc/sysconfig/network-devices/ifup /sbin/ifup | ||
ln -sf /etc/sysconfig/network-devices/ifdown /sbin/ifdown | ln -sf /etc/sysconfig/network-devices/ifdown /sbin/ifdown | ||
− | |||
− | |||
− | |||
− | |||
= Contents = | = Contents = | ||
Line 183: | Line 242: | ||
netplugd: a daemon which automatically brings your network interface up/down based on cable insertion/removal. | netplugd: a daemon which automatically brings your network interface up/down based on cable insertion/removal. | ||
+ | |||
+ | [[Category:Network Utilities]] |
Latest revision as of 17:18, 19 March 2009
Contents
Introduction to Netplug
Netplug is a Linux daemon that brings up/down network interfaces in response to network cables being plugged in and out. This application is mostly useful for a laptop or computer (used for lan parties?) that is often relocated to different LANs.
The netplugd rc script shared below replaces the clfs-bootscripts network script. If you remove the network script and symlinks in the rc#.d directories, and later decide you want them, then merely reinstall from the clfs-bootscripts.
Project Homepage: Unknown
Dependencies
Configuration Information
This package does not use a configure script. Any additional configuration must be made within the Makefile.
Non-Multilib
Modify the Makefile:
remove=" -ggdb3 " [[ " ${CFLAGS} " == *" -O"[0-9]" "* ]] && remove="${remove}-O3 " sed -i -e "s/${remove}/ /" Makefile sed -i '/bk_root/,$d' Makefile
Compile the package:
patch -Np0 -i ../netplug-1.2.9-gcc4-1.patch && patch -Np1 -i ../netplug-1.2.9-remove-nest-1.patch && patch -Np1 -i ../netplug-1.2.9-ignore-wireless-1.patch && make
Install the package:
make install
Command Explanations
remove... |
[[ "$C... |
sed -i...: These commands remove -O3 (if you are using another optimization) and debugging from the Makefile.
sed -i '/bk_root/,$d' Makefile: This removes the bitkeeper stuff, you might omit this if you are using it. MultilibThis package does not install any libraries so only one installation is needed. 32BitModify the Makefile: remove=" -ggdb3 " [[ " ${CFLAGS} " == *" -O"[0-9]" "* ]] && remove="${remove}-O3 " sed -i -e "s/${remove}/ /" Makefile sed -i '/bk_root/,$d' Makefile Compile the package: patch -Np0 -i ../netplug-1.2.9-gcc4-1.patch && patch -Np1 -i ../netplug-1.2.9-remove-nest-1.patch && patch -Np1 -i ../netplug-1.2.9-ignore-wireless-1.patch && make CC="gcc ${BUILD32}" Install the package: make install N32Modify the Makefile: remove=" -ggdb3 " [[ " ${CFLAGS} " == *" -O"[0-9]" "* ]] && remove="${remove}-O3 " sed -i -e "s/${remove}/ /" Makefile sed -i '/bk_root/,$d' Makefile Compile the package: patch -Np0 -i ../netplug-1.2.9-gcc4-1.patch && patch -Np1 -i ../netplug-1.2.9-remove-nest-1.patch && patch -Np1 -i ../netplug-1.2.9-ignore-wireless-1.patch && make CC="gcc ${BUILDN32}" Install the package: make install 64BitModify the Makefile: remove=" -ggdb3 " [[ " ${CFLAGS} " == *" -O"[0-9]" "* ]] && remove="${remove}-O3 " sed -i -e "s/${remove}/ /" Makefile sed -i '/bk_root/,$d' Makefile Compile the package: patch -Np0 -i ../netplug-1.2.9-gcc4-1.patch && patch -Np1 -i ../netplug-1.2.9-remove-nest-1.patch && patch -Np1 -i ../netplug-1.2.9-ignore-wireless-1.patch && make CC="gcc ${BUILD64}" Install the package: make install ConfiguringThe rc script below is customized for a CLFS system. Feel free to modify this as necessary for your system. Create the netplugd script: cat > /etc/rc.d/init.d/netplugd << EOF #!/bin/sh ######################################################################## # Begin $rc_base/init.d/netplugd # # Description : Netplugd-1.2.9 # # Authors : Harvey Muller # # Version : 00.02 # # Notes : Still beta # ######################################################################## . /etc/sysconfig/rc . ${rc_functions} if [ ! -x /sbin/netplugd ]; then echo "/sbin/netplugd missing, or needs to be installed ..." exit 1 fi # Use netplugd if present, it supplies NETPLUGDARGS if needed. if [ -f /etc/sysconfig/netplugd ]; then . /etc/sysconfig/netplugd fi if [ `id -u` != "0" ] && [ "$1" = "start" -o "$1" = "stop" ] ; then echo "You must be root to start, stop or restart netplugd." exit 1 fi case "${1}" in start) boot_mesg "Starting network plug daemon..." loadproc /sbin/netplugd ${NETPLUGDARGS} -p /var/run/netplugd.pid RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/netplugd ;; stop) boot_mesg "Stopping network plug daemon..." killproc netplugd RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/netplugd ;; restart|reload) ${0} stop ${0} start ;; status) statusproc netplugd RETVAL=$? ;; condrestart) [ -f /var/lock/subsys/netplugd ] && restart || : ;; *) echo "Usage: ${0} {start|stop|reload|restart|status|condrestart}" exit 1 ;; esac exit $RETVAL # End $rc_base/init.d/netplugd EOF The bootscripts network rc script is no longer necessary. You may remove the network script and symlinks with these commands: rm -rf /etc/rc.d/init.d/network rm -rf /etc/rc.d/rc*.d/{S2,K8}0network Create symlinks to netplugd script: ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc0.d/K80netplugd ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc1.d/K80netplugd ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc2.d/S20netplugd ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc3.d/S20netplugd ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc4.d/S20netplugd ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc5.d/S20netplugd ln -sf /etc/rc.d/init.d/netplugd /etc/rc.d/rc6.d/K80netplugd If you have configured your wired interface through udev (or other means) to be named eth0, and you only have one wired interface, then we may as well configure netplug to use it only: sed -i 's/eth\*/eth0/' /etc/netplug/netplugd.conf Netplug requires the /var/lock/subsys directory be present, and the Makefile doesn't create it: [ -d /var/lock/subsys ] || install -d -m755 /var/lock/subsys You could just modify the policy agent to reflect the CLFS locations, but let's make links in /sbin for ifup and ifdown: ln -sf /etc/sysconfig/network-devices/ifup /sbin/ifup ln -sf /etc/sysconfig/network-devices/ifdown /sbin/ifdown ContentsInstalled Programs: /sbin/netplugd Installed Libraries: none Installed Directories: /etc/netplug, /etc/netplug.d, /var/lock/subsys Installed Scripts: /etc/netplug.d/netplug, /etc/rc.d/init.d/netplugd Installed Documentation: /usr/share/man/man8/netplugd.8 Short Descriptionsnetplugd: a daemon which automatically brings your network interface up/down based on cable insertion/removal. |