Adding new class computer without modifying dhcpd.conf
Sébastien GALLET
sgallet at ibourgogne.net
Sun Aug 1 14:17:08 CEST 2004
Hi all,
When installing new computers with FAI, you need to update dhcpd.conf
(and restart dhcpd server).
With this little patch, these modifications are not necessary
--- /usr/lib/fai/sbin/rcS_fai.orig 2004-08-01 13:20:12.000000000 +0200
+++ /usr/lib/fai/sbin/rcS_fai 2004-08-01 13:23:47.000000000 +0200
@@ -137,6 +137,17 @@
# these tasks can define variables, that are needed later
task confdir
+
+ namefrommac=`$FAI/hostfrommac`
+ echo hostname = $namefrommac
+ if [ ! -z $namefrommac ]; then
+ sndmon "change HOSTNAME to $namefrommac"
+ HOSTNAME=$namefrommac
+ else
+ HOSTNAME=`uname -n | cut -d. -f1`
+ fi
+ export HOSTNAME
+
task setup
task defclass
task defvar
--- /usr/bin/fai-class.orig 2004-08-01 13:49:27.000000000 +0200
+++ /usr/bin/fai-class 2004-08-01 13:49:46.000000000 +0200
@@ -131,7 +131,7 @@
verbosemsg "Setting LOGDIR to default value /tmp/fai"
LOGDIR=/tmp/fai; export LOGDIR
fi
- HOSTNAME=`uname -n | cut -d. -f1`; export HOSTNAME
+# HOSTNAME=`uname -n | cut -d. -f1`; export HOSTNAME
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main program
Now create a script "hostfrommac" in /fai. This small script maps a MAC
address to a class name :
#!/bin/sh
INT=eth0
STATE=`ifconfig $INT | grep "inet addr"`
if [ -z "$STATE" ]; then
INT=eth1
STATE=`ifconfig $INT | grep "inet addr"`
fi
echo "Find active network interface : $INT" >> /tmp/fai/rcS.log
# Mac Address Mapping
MAC_ADDR=`ifconfig $INT | grep HWaddr | sed -e "s/.*HWaddr //" | sed -e
"s/ //g" | tr '[:lower:]' '[:upper:]'`
echo "MAC_ADDR = $MAC_ADDR ." >> /tmp/fai/rcS.log
case $MAC_ADDR in
00:50:FC:73:E7:CE)
echo "$MAC_ADDR found" >> /tmp/fai/rcS.log
echo model00
;;
00:60:08:79:00:7E)
echo "$MAC_ADDR found" >> /tmp/fai/rcS.log
echo model00
;;
*) echo "Cant find a class for $MAC_ADDR" >> /tmp/fai/rcS.log
esac
Now, create nfsroot with fai-setup
That works for me (Sarge i386)
Regarde
Sébastien
More information about the linux-fai
mailing list