Custom scripts for configuring your network interfaces in Slackware.
They are to be used in conjunction with the enhanced rc.inet1 and rc.wireless
scripts that you find in the parent directory.

===============================================================================

How do you start using these scripts and what can they do for your computer?

===============================================================================

The previous few releases of Slackware Linux have seen many changes in the
network configuration scripts, rc.inet1 and rc.wireless. There's a zillion
other changes that you could think of, that are unlikely to ever appear in
Slackware. So, in order for all you hackers to configure your network
interfaces just the way you want to, I added the possibility to run your own
script when an interface is being configured by rc.inet1.

These are the steps you have to take, if you want to start experimenting with
the new features:

(1) Download rc.inet1 and rc.wireless and let them replace your current
    scripts. Look for the differences between your old rc.inet1.conf and
    the new one, so that you can determine what is new.
    Basically, these parameters were added:
    SCRIPT[]=""
    DHCP_TIMEOUT[]=""
    WLAN_WPAWAIT[]=""
    Even without the next steps, these modified scripts will give the
    exact same functionality you have at the moment. You could already set
    DHCP_TIMEOUT[0]="10" for your wired interface to get back the
    behaviour of the dhcp client in Slackware 10.1 and before (10 second
    timeout). You can let the wireless script wait longer than the default
    10 seconds for WPA association by adding WLAN_WPAWAIT[1]="60" to the
    parameters for your wireless interface in rc.inet1.conf...

(2) Download the ifcfg/ directory and the scripts contained therein. You
    can put those scripts anywhere, I made a directory /etc/rc.d/ifcfg/
    and put them there. It's the SCRIPT[] parameter value where you put
    the full pathname to such a script, or if you want to run more than one
    script, use the SCRIPTROOT parameter to set the pathname and use relative
    filenames in the SCRIPT parameter..

Now the fun starts! I have written a couple of example scripts, you will find
them here, called ifplugd.sh and ifmetric.sh. These two scripts require two
pieces of software, ifplugd and ifmetric, for which I supply Slackware packages
on this web site (search the slackbuilds directory).
The purpose of the example scripts is to show how a script must be constructed,
but they also provide real added functionality. 
- ifplugd.sh will tell ifplugd to watch your (wired) network connection and
  take appropriate action: unconfigure the device when you unplug the network
  cable, and re-configure it when you plug it back in.
- ifmetric.sh can be used to give higher or lower priority to one of your
  network interfaces.
The combination of both makes it possible that you can use a laptop with wired
and wireless interface, and switch from wired to wireless and back by merely
un- and re-plugging your network cable. The scripts work in such a way that the
fastest interface is the preferred route for outbound traffic. You choose which
is the fastest interface of course! For me, my laptop's wireless interface at
54 Mbps has a lower bandwidth than my 1 Gbps wired interface. So, when a wired
connection is present, I want my network traffic to use the gigabit interface.
When the cable is unplugged, I want the laptop to switch over to wireless. 
Actually, the wireless interface will be configured with an IP address all the
time, but the changed metric will prevent it from being used for network
traffic when a wired connection is present.

These are the extra steps to take:

(3) Download and install (or re-build and then install) the packages for
    ifplugd (which needs the libdaemon package as well) and ifmetric.

(4) For your wired interface add this line to rc.inet1.conf:
    SCRIPT[0]="/etc/rc.d/ifcfg/ifplugd.sh"
    Make sure you put the correct index where I put [0], and the correct
    pathname to the downloaded "ifplugd.sh" script.

(5) For your wireless interface add this line to rc.inet1.conf:
    SCRIPT[1]="/etc/rc.d/ifcfg/ifmetric.sh"
    Make sure you put the correct index where I put [1], and the correct
    pathname to the downloaded "ifmetric.sh" script.

=== 

That is enough to enable the magic. Restart the interfaces, or reboot the PC.
Unplug the network cable, or boot with the cable unplugged, watch what that
does to the IP address and routing table. Do you still see a delay when
Slackware waits for the dhcp client to time out when your cable is unplugged
on boot?  NO !!!
Watch what changes in your network configuration when the cable is plugged
back in again. You will notice that ifplugd will keep eth0 up, so that it can
keep an eye on the link status of the interface.
You should stay online no matter what happens to the network connections
(unless they all fail together of course...).

===

Another script is available, called 'wakeonlan.sh'. Network interfaces that
support WOL, can be put in a state at shutdown where they keep listening for
a 'magic packet' that arrives from the network, even when the PC is powered
off. You can start your PC by sending a network packet to the card from
another PC in your network. Suppose you want to run both the ifplugd.sh and
the wakeonlan.sh for your wired interface? Use the SCRIPTROOT parameter to
define the directory where you keep your scripts, abd put both script filenames
in the SCRIPT parameter, separated by a space.
For example, write these two lines in rc.inet1.conf:

    SCRIPTROOT[0]="/etc/rc.d/ifcfg"
    SCRIPT[0]="ifplugd.sh wakeonlan.sh"

If a script's name in the SCRIPT parameter does not start with a '/',
it is not an absolute pathname, and the value of SCRIPTROOT will be added
in front of the script's name.

===============================================================================
Eric Hameleers <alien at slackware dot com> last change 04-mar-2007