[arch] Initscripts w/ Network Profiles

Judd Vinet jvinet at zeroflux.org
Tue May 3 15:31:42 EDT 2005


Hey all,

I made an attempt at adding network profiles to our initscripts.

Basically, I just removed the INTERFACES and ROUTES arrays, replacing
them with a NET_PROFILES array.

The idea is this:  the admin defines as many interfaces and routes as
s/he wants (they don't have to be named after the real interface name).
Then s/he "links" an interface with zero or more routes by defining a
network profile.  The NET_PROFILES array contains the names of all
network profiles to be started at boot-up.

Here's an example:

------------------------------------------------------------- snip --
# Interfaces
if_lo="lo 127.0.0.1"
if_eth0_home="eth0 192.168.1.2 netmask 255.255.255.0"
if_eth0_away="eth0 dhcp"
if_eth1="eth1 192.168.0.2 netmask 255.255.255.0"

# Routes
rt_gateway="default gw 192.168.0.1"
rt_wlan_gw="default gw 192.168.1.1"

# Profiles
#   (the first entry is always the interface -- the others are routes)
prof_lo="if_lo"
prof_wlan_home="if_eth0_home rt_wlan_gw"
prof_wlan_school="if_eth0_away"
prof_wired="if_eth1 rt_gateway"

NET_PROFILES=(prof_lo prof_wlan_home !prof_wlan_school !prof_wired)
------------------------------------------------------------ /snip --




And in my /etc/conf.d/wireless, I would have something like this:

------------------------------------------------------------- snip --
wlan_if_eth0_home="eth0 mode managed essid mylan"
wlan_if_eth0_away="eth0 mode managed essid school"
------------------------------------------------------------ /snip --

Note that the wlan_* variable has to be of the form wlan_${IF}, where
${IF} is the name of the interface variable defined in rc.conf.


The profile stuff adds a bit more complexity to the setup, but it is
indeed more powerful.  One can run
"/etc/rc.d/network start <profile_name>" to bring up any network
profile, making it easy to switch between network setups without
juggling config files or rebooting.

eg,
# /etc/rc.d/network stop prof_wlan_home
# /etc/rc.d/network start prof_wlan_school

If you're interested, please test it out and give me feedback.  It's
only been minimally tested by myself so far, so there's probably bugs or
logical black holes somewhere.  I still have to fix up the inelegant
error handling, verbosity and whatnot -- this one is just a prototype.

# pacman -U http://www.archlinux.org/~judd/initscripts-0.7-10.pkg.tar.gz


Thanks.


- J





More information about the arch mailing list