[debian-lan-devel] [SCM] Debian-LAN development and packaging branch, squeeze, updated. 0.6-18-g763b078

Andreas B. Mundt andi at debian.org
Sun Sep 2 10:27:22 UTC 2012


The following commit has been merged in the squeeze branch:
commit d910b48b5da75f02b6c532729408a1d9057ad9e6
Author: Andreas B. Mundt <andi at debian.org>
Date:   Sun Sep 2 12:04:53 2012 +0200

    Cherry-picked improvements of  debian-lan script.
    
    The script debian-lan uses the kernel's ARP cache now to look for
    candidates to be added to DHCP.
    
    HOWTO (mass) add machines:
      - switch on all machines you want to add and PXE boot
      - make sure no 'foreign' machines are in the network or note their
        hardware (MAC) address
      - eventually wait a bit, until all unwanted entries have vanished
        from the ARP cache
      - run 'debian-lan add2dhcp' and choose the machine's type

diff --git a/fai/config/files/usr/local/sbin/debian-lan/SERVER_A b/fai/config/files/usr/local/sbin/debian-lan/SERVER_A
index e15f3f4..4186bcb 100755
--- a/fai/config/files/usr/local/sbin/debian-lan/SERVER_A
+++ b/fai/config/files/usr/local/sbin/debian-lan/SERVER_A
@@ -40,10 +40,11 @@ usage(){
     exit 1
 }
 
-nscd_restart(){
+sync_nscd(){
     if pidof nscd 1>&2 > /dev/null ; then
-	## Restart nscd to have database up to date:
-	/etc/init.d/nscd restart
+        ## Clear tables to have database up to date:
+	nscd -i passwd
+	nscd -i group
     fi
 }
 
@@ -92,7 +93,7 @@ shift
 
 case $COMMAND in
     adduser)
-	nscd_restart
+	sync_nscd
 	if [ -r $1 ] ; then
 	    ## We have a file, one user per line.
 	    chmod 600 $1
@@ -128,7 +129,7 @@ case $COMMAND in
 	fi
 	;;
     deluser)
-	nscd_restart
+	sync_nscd
 	if [ -r $1 ] ; then
 	    ## We have a file, one user per line.
 	    cat $1 | while read LINE; do
@@ -183,8 +184,12 @@ EOF
 	echo
 	;;
     add2dhcp)
-	locHW=`ifconfig -a | grep -o "\w\{2\}:\w\{2\}:\w\{2\}:\w\{2\}:\w\{2\}:\w\{2\}"`
-	allHW=`grep -o "\w\{2\}:\w\{2\}:\w\{2\}:\w\{2\}:\w\{2\}:\w\{2\}" /var/log/syslog | sort -u`
+	## GW: gateway hardware address
+	GW=`ip route show | grep default | egrep -o '[1-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'`
+	## locHW: all local hardware addresses
+	locHW=`ip addr show | grep -o "\w\{2\}:\w\{2\}:\w\{2\}:\w\{2\}:\w\{2\}:\w\{2\}" | sort -u | sed '1d;$d'`
+	## allHW: all known hardware addresses with gateway address removed
+	allHW=`ip neigh show | sed "/$GW/d" | grep -o "\w\{2\}:\w\{2\}:\w\{2\}:\w\{2\}:\w\{2\}:\w\{2\}" | sort -u`
 	for HWaddr in $allHW ; do
 	    if echo $locHW | grep -q $HWaddr ; then
 		echo "Skipping local MAC address: ${HWaddr}"

-- 
Debian-LAN development and packaging



More information about the debian-lan-devel mailing list