Simplifying the LFS Bootscripts

Ian Molton spyro at f2s.com
Sun Jan 9 09:41:48 PST 2005


Alexander E. Patrakov wrote:

> 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

I dont like this.

conceptually, the up and down are merely the parts reading

ip link set eth1 {up,down}

and I personally think its bad practice to -up an inetrface before 
setting up the addresses its going to have assigned to it.

the up and downing should be handled by a generic script or function 
that *only* does that.

I recon the /etc/sysconfig/network-devices/eth1 file should contain:

ONBOOT=yes
ADDR=192.168.0.101/24 broadcast 192.168.0.255
ADDR=192.168.0.102/24 broadcast 192.168.0.255
GATEWAY=192.168.0.1

Or something similar.

the dev eth1 is implicit in that the file is named 
/etc/sysconfig/network-devices/***eth1***

and the up and downing process shouldnt be part of the configuration 
file, it should be part of the script that interprets the file.

IOW, the script would be passed the up/down parameter, and would read 
/etc/sysconfig/network-devices/eth1 to discover that it should up or 
down the interface. it could also add / delete the addresses.

Also your proposal leaves open a wide margin for sut-n-paste errors in 
that people will copy the 'add' lines and use them for the 'del' lines 
too, just changing the add to a del (or more likely, forgetting to).

-1 here.



More information about the lfs-dev mailing list