[debian-lan-devel] [SCM] Debian-LAN development and packaging branch, master, updated. 3830a49979c53ef2938633e036adc60eb52aa954

Andreas B. Mundt andi.mundt at web.de
Sat Jan 28 10:20:30 UTC 2012


The following commit has been merged in the master branch:
commit 3830a49979c53ef2938633e036adc60eb52aa954
Author: Andreas B. Mundt <andi.mundt at web.de>
Date:   Sat Jan 28 11:18:06 2012 +0100

    Add command 'add2dhcp' to the debian-lan script to add HW addresses
    found in the sytem log to dhcpd.conf.

diff --git a/fai/config/files/usr/sbin/debian-lan/SERVER_A b/fai/config/files/usr/sbin/debian-lan/SERVER_A
index 8a79139..c5b13f5 100755
--- a/fai/config/files/usr/sbin/debian-lan/SERVER_A
+++ b/fai/config/files/usr/sbin/debian-lan/SERVER_A
@@ -9,6 +9,7 @@ DATADIR="/root/installation/"
 #KADMINOPTION="-force"
 HOSTNAME=`hostname -s`
 HOME="/lan/$HOSTNAME/home0"
+DHCPCONF="/etc/dhcp/dhcpd.conf"
 
 usage(){
     echo "Usage: debian-lan  command  argument"
@@ -31,6 +32,10 @@ usage(){
     echo "  addmachine list"    
     echo "   \"list\" is a list of host names."
     echo
+    echo "  add2dhcp workstation|diskless"    
+    echo "   All nonlocal hardware MAC addresses found in the syslog are added"
+    echo "   to '$DHCPCONF', either as workstation or diskless machine."
+    echo
     exit 1
 }
 
@@ -177,6 +182,23 @@ EOF
         done
 	echo
 	;;
+    add2dhcp)
+	NAME=$1
+	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`
+	for HWaddr in $allHW ; do
+	    if echo $locHW | grep -q $HWaddr ; then
+		echo "Skipping local MAC address: ${HWaddr}."
+		continue
+	    elif grep -q $HWaddr $DHCPCONF; then
+		echo "Foreign MAC address $HWaddr already found in '${DHCPCONF}'."
+	    else
+		sed -i "0,/\(host ${NAME}.*\) A1:B2:C3:D4:E5:\w\{2\};/s//\1 ${HWaddr};/" ${DHCPCONF}
+		echo "Adding foreign MAC address $HWaddr to '${DHCPCONF}'."
+	    fi
+	done
+	;;
+    
     *)
 	usage
 	;;

-- 
Debian-LAN development and packaging



More information about the debian-lan-devel mailing list