Roy's Blog

A Hacker's musings on Code | Tech | Life

As requested via a bug report, network configuration now supports bash expansion. This will make giving servers multiple IP addresses a snap. Here's an example

config_eth0=( "192.168.0.{1..20}/24 brd +" ) gives you 20 IP addresses.

config_eth0=( "192.168.{1..20}.{1..20}/24 brd +" ) gives you 400 IP addresses. (20x20)

config_eth0=( "192.168.{1..20}.{1..20}/24 brd 192.168.{1..20}.{1..20}" )
Currently doesn't work as expected - it tries to add 160000 IP addresses with most of them duplicates thanks to a sequence in the broadcast field. Not sure how to solve this at present - but I don't see it as that much of a problem at this time.

The problem is that to get the first two examples working correctly, I need to replace spaces with _ (any char will do as long as it's not space) so that expansion works just by clever use of quoting and arrays - no loops.

Here's the current code - which accepts a string and returns an array

expand_parameters() {
    local x="$( eval echo ${@// /_} )"
    local -a a=( ${x} )
    a=( "${a[)
    a=( "${a[@](@]/#/\"}")/%/\"}" )
    echo "${a[*]//_/ }"

Any ideas about how to fix it are welcome :)

Continue reading...

Merged some patches by Paul Pacheco into baselayout which makes parallel start much more parallel and only does a modules-update when needed. This boosts booting my laptop by around 40 seconds!The only down side is that I've had to hide the init.d/* script output and replace it with generic Service Foo starting/started/stopped/failed messages as the output no longer lines up as we're running parallel.

Continue reading...