On 06/06/2011 02:50 PM, Michael Tautschnig wrote:
I have an installation of fai in a cluster in the University of Buenos
Aires. I have a problem with the machine name detection. My clients machines
have two network cards and both are configured by dhcp.
When the machine start to install, it load by one of the cards. But, when it
detect the classes, it detect the other network card.
My question is about, When the scripts detect the machine name?.
The hostname should either get set from kernel command line parameters (you
might have set them using fai-chboot) or will be provided by DHCP. I couldn't
really think of another option, unless you are modifying it in any of your
class/* scripts.

FWIW, we set our own "newhost" kernel parameter which we enable via "fai-chboot" (eg: fai-chboot -k newhost=mymachine ...).

The "newhost" kernel parameter is checked by our "/srv/fai/config/hooks/setup.DEFAULT.source" (attached). As a fallback, if neither the HOSTNAME nor newhost variables are set, the hostname is set to be the ip-address of eth0, with dots converted to dashes.

So far, this reliably sets the hostname to the value of newhost in the newly installed target system.

--
Rob

#!/bin/bash

export MemoryTotalBytes=$(expr $(sed -n 's/^MemTotal:  *\([0-9]*\)[^0-9]*/\1/p' 
/proc/meminfo) '*' 1024)

get_ip() {
        /sbin/ifconfig ${IFACE:-${INTERFACE:-eth0}} | sed -n '
                /^.*[[:space:]]inet addr:/ {
                        s///
                        s/[[:space:]].*//
                        p
                }
        '
}

if [ -z "$HOSTNAME" ] || [ "$HOSTNAME" = host ]
then
        if [ -z "$newhost" ]
        then
                export newhost=$(get_ip | sed 's/\./-/g')
        fi
        export HOSTNAME="$newhost"
        hostname "$HOSTNAME"
        echo "$HOSTNAME" > /etc/hostname
        if [ -d "$target/etc/" ]
        then
                echo "$HOSTNAME" > "$target/etc/hostname"
        fi
fi

Antwort per Email an