The attached patch now provides the mask as well. It is included in
3.2.18+experimental23.

Best,
Michael

2009-03-21  Luk Claes  <luk.cl...@ugent.be>

        * debian/control: Depends: iproute for fai-client, fai-server.
        * fai-setup, make-fai-nfsroot: Replaced all calls to ifconfig by proper 
ip +
                shell magic calls (closes: #524347).
        * subroutine-linux, get-boot-info, task_sysinfo: Likewise.
        * simple example: Likewise.
Index: trunk/bin/fai-setup
===================================================================
--- trunk.orig/bin/fai-setup
+++ trunk/bin/fai-setup 
@@ -115,7 +115,7 @@
            [ -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)
+           ips=$(ip addr | grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2 | 
grep -v 127.0.0.1)
            for ip in $ips; do
                hname=$(getent hosts $ip| tr -s ' ' ',')
                [ -z "$hname" ] && hname=$ip
@@ -176,13 +176,12 @@
     test -f /etc/init.d/nfs-kernel-server && nfsserver=nfs-kernel-server
     test -f /etc/init.d/nfs-user-server && nfsserver=nfs-user-server
 
-    addr=$(LC_ALL=C ifconfig $SERVERINTERFACE | grep -v 127.0.0.1 | perl -ne 
'/addr:([\d.]+)/ && print"$1\n"'|head -1)
-    mask=$(LC_ALL=C ifconfig $SERVERINTERFACE | grep -v 127.0.0.1 | perl -ne 
'/Mask:([\d.]+)/ && print"$1\n"'|head -1)
+    addr=$(ip addr show dev $SERVERINTERFACE | grep -w inet | cut -d t -f 2 | 
cut -d ' ' -f 2 | cut -d / -f 1 | grep -v 127.0.0.1 | head -1)
 
     if expr match "$FAI_CONFIG_SRC" 'nfs:\/\/' > /dev/null; then
-        add_export_line $FAI_CONFIGDIR  
"$addr/$mask(async,ro,no_subtree_check)"
+        add_export_line $FAI_CONFIGDIR  "$addr(async,ro,no_subtree_check)"
     fi
-    add_export_line $NFSROOT  
"$addr/$mask(async,ro,no_subtree_check,no_root_squash)"
+    add_export_line $NFSROOT  "$addr(async,ro,no_subtree_check,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."
Index: trunk/bin/make-fai-nfsroot
===================================================================
--- trunk.orig/bin/make-fai-nfsroot
+++ trunk/bin/make-fai-nfsroot  
@@ -248,7 +248,7 @@
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 add_all_host_entries() {
 
-    local ips=$(ifconfig | grep -w inet | cut -d : -f 2 | cut -d ' ' -f 1 | 
grep -v 127.0.0.1)
+    local ips=$(ip addr | grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2 | cut 
-d / -f 1 | grep -v 127.0.0.1)
     for eth in $ips; do
        getent hosts $eth >> etc/hosts || true
     done
Index: trunk/debian/control
===================================================================
--- trunk.orig/debian/control
+++ trunk/debian/control        
@@ -13,7 +13,7 @@
 Package: fai-client
 Architecture: all
 Section: admin
-Depends: perl, file, libapt-pkg-perl, libparse-recdescent-perl, 
liblinux-lvm-perl, net-tools
+Depends: perl, file, libapt-pkg-perl, libparse-recdescent-perl, 
liblinux-lvm-perl, iproute
 Recommends: debconf-utils, cfengine2
 Suggests: ntfsprogs, dmsetup, cryptsetup, logtail
 Conflicts: fai, fai-kernels
@@ -46,7 +46,7 @@
 Architecture: all
 Section: admin
 Depends: fai-client, debootstrap
-Recommends: nfs-kernel-server, dhcp3-server | bootp, tftpd-hpa | tftpd, 
openssh-server, openssh-client, syslinux-common, openbsd-inetd | 
inet-superserver
+Recommends: nfs-kernel-server, dhcp3-server | bootp, tftpd-hpa | tftpd, 
openssh-server, openssh-client, syslinux-common, openbsd-inetd | 
inet-superserver, iproute
 Suggests: debmirror, apt-move, genisoimage, grub, aptitude, perl-tk, 
libproc-daemon-perl
 Conflicts: fai
 Replaces: fai
Index: trunk/examples/simple/files/etc/rc2.d/S99fai-setup/FAISERVER
===================================================================
--- trunk.orig/examples/simple/files/etc/rc2.d/S99fai-setup/FAISERVER
+++ trunk/examples/simple/files/etc/rc2.d/S99fai-setup/FAISERVER        
@@ -13,7 +13,7 @@
 
 # setup network
 dhclient eth0  # connection to the outside world (hopefully)
-ifconfig eth0:1 192.168.1.250 # (fixed address of faiserver)
+ip addr add 192.168.1.250 dev eth0 # (fixed address of faiserver)
 /etc/init.d/nscd restart
 /etc/init.d/apache2 restart
 /etc/init.d/apt-proxy restart
Index: trunk/lib/get-boot-info
===================================================================
--- trunk.orig/lib/get-boot-info
+++ trunk/lib/get-boot-info     
@@ -41,14 +41,14 @@
 netdevice_info() {
 
     # devices that are running
-    netdevices_up=$(ifconfig | perl -anF'\s+' -e 'print "$F[0]\n" if $F[0];' | 
grep -v "^lo" | sort | uniq)
+    netdevices_up=$(ip link | grep "^[1-9$]" | cut -d : -f 2 | cut -d ' ' -f 2 
| grep -v "^lo" | sort | uniq)
     # netdevices is the list of ethernet devices which will be used for bootpc 
(maybe dhcp)
     # if not defined, use boot messages to determine network devices
     [ -n "$netdevices" ] || netdevices=$netdevices_up
 
     # some network driver do not echo eth0,..; they are not detected
     netdevices_all=$(dmesg| perl -ne 'print $&,"\n" if m/\beth[0-9]\b/')
-    tmp=$(ifconfig -a | awk '/^eth/ { print $1 }')
+    tmp=$(ip link | grep "^[1-9]" | cut -d : -f 2 | cut -d ' ' -f 2 | grep 
"^eth")
     netdevices_all="$netdevices_all $tmp"
     netdevices_all=$(for dev in $netdevices_all; do echo $dev; done| sort | 
uniq)
 
Index: trunk/lib/subroutines-linux
===================================================================
--- trunk.orig/lib/subroutines-linux
+++ trunk/lib/subroutines-linux 
@@ -270,7 +270,7 @@
 
     if [ $do_init_tasks -eq 1 ] ; then
        # show some local information
-       ifconfig; df
+       ip addr; df
        # umount swap space
        swapoff -a
     fi
Index: trunk/lib/task_sysinfo
===================================================================
--- trunk.orig/lib/task_sysinfo
+++ trunk/lib/task_sysinfo      
@@ -26,7 +26,7 @@
 lsusb
 echo "Ethernet cards found: $netdevices_all"
 echo "Ethernet cards running: $netdevices_up"
-ifconfig -a
+ip addr
 
 [ -x "$(which sysinfo)" ] && sysinfo -class device -level all
 

Attachment: pgpfjt4A5SAqZ.pgp
Description: PGP signature

Reply via email to