Simplifying the LFS Bootscripts

Alexander E. Patrakov patrakov at ums.usu.ru
Sat Jan 8 22:06:42 PST 2005


Nathan Coulson wrote:

<a suggestion to simplify the bootscripts>

For network, I suggest (sorry, that's only a draft, sample implementation is
not available yet, but should be trivial) the following configuration
mechanism that's simpler and has at least the same flexibility as the
existing one.

1) Each interface configuration resides in one file
in /etc/sysconfig/network-devices. Its name should be constructed as
follows: Optional 2-digit number for the ordering and some string that you
can pass to ifup. E.g., the following names are valid: 50eth0, 75sit1,
ppp0, wlan0, and you can provide eth0, sit1, ppp0, wlan0 as arguments to
ifup.

2) The contents of this file should be as follows: Optional ONBOOT=yes_or_no
and (for the future) ONHOTPLUG=yes_or_no lines (checked by ifup, not
network), followed by user-written up() and down() functions that are valid
according to /bin/sh syntax rules and are supposed to be sourced from ifup.
Error checking is done in the ifup and ifdown scripts by doing a "trap ...
ERR" and notifying the caller if at least one error occurs.

E.g., consider this example for two IPv4 addresses and a static route:

# Begin /etc/sysconfig/network-devices/eth1

ONBOOT=yes

up() {
 ip link set eth1 up
 ip addr add 192.168.0.101/24 broadcast 192.168.0.255 dev eth1
 ip addr add 192.168.0.102/24 broadcast 192.168.0.255 dev eth1
 ip route add 192.168.0.0/16 via 192.168.0.1
}

down() {
 ip route del 192.168.0.0/16 via 192.168.0.1
 ip addr del 192.168.0.102/24 broadcast 192.168.0.255 dev eth1
 ip addr del 192.168.0.101/24 broadcast 192.168.0.255 dev eth1
 ip link set eth1 down
}

# End /etc/sysconfig/network-devices/eth1

-- 
Alexander E. Patrakov



More information about the lfs-dev mailing list