[Fai-commit] r3762 - trunk/bin

fai-commit at lists.alioth.debian.org fai-commit at lists.alioth.debian.org
Sun Aug 6 20:18:06 UTC 2006


Author: lange
Date: 2006-08-06 20:18:04 +0000 (Sun, 06 Aug 2006)
New Revision: 3762

Modified:
   trunk/bin/fai-setup
Log:
do not use SERVERINTERFACE of determine hostname, add all IP addresses
and host names to ssh_known_hosts,
remove variable FAICLIENTS, use IP address and netmask for exportfs line


Modified: trunk/bin/fai-setup
===================================================================
--- trunk/bin/fai-setup	2006-08-06 19:57:43 UTC (rev 3761)
+++ trunk/bin/fai-setup	2006-08-06 20:18:04 UTC (rev 3762)
@@ -100,15 +100,17 @@
 	#Adding servers keys to known_hosts list of LOGUSER. 
 	#So that installed clients can ssh $LOGUSER@$HOSTNAME without password
 	if [ ! -f $sshdir/known_hosts ]; then
-	    echo "Using interface $SERVERINTERFACE to determine local hostname."
-	    SERVERIP=$(LC_ALL=C ifconfig $SERVERINTERFACE | perl -ne '/addr:([\d.]+)/ && print "$1\n"')
-	    HOSTNAME=$(getent hosts $SERVERIP | perl -p -e 's/[\d.\s]*([\w-]*).*// && print $1')
-	    echo "Adding $HOSTNAME to known_hosts."
-	    [ -f /etc/ssh/ssh_host_dsa_key.pub ] && DSASERVER=$( cat /etc/ssh/ssh_host_dsa_key.pub | sed -e "s/= .*$/=/")
-	    [ -f /etc/ssh/ssh_host_rsa_key.pub ] && RSASERVER=$( cat /etc/ssh/ssh_host_rsa_key.pub | sed -e "s/= .*$/=/")
-	
-	    [ -z "$DSASERVER" ] || echo "$HOSTNAME,$SERVERIP $DSASERVER" >> $sshdir/known_hosts
-	    [ -z "$RSASERVER" ] || echo "$HOSTNAME,$SERVERIP $RSASERVER" >> $sshdir/known_hosts
+	    [ -f /etc/ssh/ssh_host_dsa_key.pub ] && DSASERVER=$(sed -e "s/= .*$/=/" /etc/ssh/ssh_host_dsa_key.pub)
+	    [ -f /etc/ssh/ssh_host_rsa_key.pub ] && RSASERVER=$(sed -e "s/= .*$/=/" /etc/ssh/ssh_host_rsa_key.pub )
+	    # determine all IP addresses, and their host names
+	    ips=$(LC_ALL=C ifconfig| perl -ne '/addr:([\d.]+)/ && print"$1\n"'|grep -v 127.0.0.1)
+	    for ip in $ips; do
+		hname=$(getent hosts $ip| tr -s ' ' ',')
+		[ -z "$hname" ] && hname=$ip
+		echo "Adding $hname to known_hosts."
+		[ -z "$DSASERVER" ] || echo "$hname $DSASERVER" >> $sshdir/known_hosts
+		[ -z "$RSASERVER" ] || echo "$hname $RSASERVER" >> $sshdir/known_hosts
+	    done
 	    echo "$sshdir/known_hosts created."
 	else
 	    echo "$sshdir/known_hosts remained unchanged."
@@ -154,8 +156,10 @@
     test -f /etc/init.d/nfs-kernel-server && nfsserver=nfs-kernel-server
     test -f /etc/init.d/nfs-user-server && nfsserver=nfs-user-server
 
-    add_export_line $FAI_CONFIGDIR  "$FAICLIENTS(async,ro)"
-    add_export_line $NFSROOT  "$FAICLIENTS(async,ro,no_root_squash)"
+    addr=$(LC_ALL=C ifconfig $SERVERINTERFACE | grep -v 127.0.0.1 | perl -ne '/addr:([\d.]+)/ && print"$1\n"')
+    mask=$(LC_ALL=C ifconfig $SERVERINTERFACE | grep -v 127.0.0.1 | perl -ne '/Mask:([\d.]+)/ && print"$1\n"')
+    add_export_line $FAI_CONFIGDIR  "$addr/$mask(async,ro)"
+    add_export_line $NFSROOT  "$addr/$mask(async,ro,no_root_squash)"
     if [ -z "$nfsserver" ]; then
 	echo "Could not find the type of your nfs server. Maybe"
 	echo "no nfs server is installed. I can't restart it."




More information about the Fai-commit mailing list