support persistent interface names across reboots
authorMichael Prokop <mika@grml.org>
Thu, 15 Mar 2007 19:38:46 +0000 (20:38 +0100)
committerMichael Prokop <mika@grml.org>
Thu, 15 Mar 2007 19:38:46 +0000 (20:38 +0100)
debian/changelog
sbin/netcardconfig

index 1d15c9f..5fa9602 100644 (file)
@@ -1,3 +1,12 @@
+grml-network (0.1-9) unstable; urgency=low
+
+  * Support generation of udev rules for persistent interface names
+    across reboots (using an autogenerated script named
+    /etc/udev/scripts/netcardconfig). Thanks for the nice idea,
+    Michael Hanscho! [Closes: issue153]
+
+ -- Michael Prokop <mika@grml.org>  Thu, 15 Mar 2007 20:37:05 +0100
+
 grml-network (0.1-8) unstable; urgency=low
 
   * grml-vpnc-tugraz: add (deactivated by default) template
index 0107ab1..75225f0 100755 (executable)
@@ -4,7 +4,7 @@
 # Authors:       Michael Prokop <mika@grml.org>, Marcel Wichern 2006, Klaus Knopper 2002, Niall Walsh + Stefan Lippers-Hollmann 2004-2007
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Sam Jän 27 19:28:54 CET 2007 [mika]
+# Latest change: Don Mär 15 20:36:48 CET 2007 [mika]
 ################################################################################
 # Changes have been merged from Kanotix's and Sidux's netcardconfig:
 # http://kanotix.com/files/debian/pool/main/n/netcardconfig-kanotix/
@@ -82,6 +82,19 @@ writeiwline() {
   #echo "DEBUG: for interfaces $IWOURLINE"
 }
 
+generate_udev_entry() {
+  interface=''
+  echo "# Auto generated script from netcardconfig on $(date)
+# Executing this script generates an entry in /etc/udev/rules.d/z25_persistent-net.rules
+# for you, please check z25_persistent-net.rules for existing entries before
+# running this script (once more)." > /etc/udev/scripts/netcardconfig
+  for interface in `ifconfig | awk '/^[a-z]/ &&!/^lo/{ print $1} '` ; do
+      echo -n "INTERFACE=$interface /lib/udev/write_net_rules " >> /etc/udev/scripts/netcardconfig && \
+      udevinfo -a -p /sys/class/net/$interface | awk -F'==' '/address/ {print $2}' >> /etc/udev/scripts/netcardconfig
+  done
+  chmod +x /etc/udev/scripts/netcardconfig && /etc/udev/scripts/netcardconfig 1>/dev/null
+}
+
 device2props() {
   PARTCOUNT=0
   isauto=0
@@ -540,7 +553,13 @@ while (true); do
     if ! ifup $DV; then
       $DIALOG --yesno "$MESSAGE14" 15 50 || IFACEDONE="DONE"
     else
-      $DIALOG --yesno "$MESSAGE15" 15 50 && addauto || remauto
+      if $DIALOG --yesno "$MESSAGE15" 12 50 ; then
+         addauto
+         # get persistent interface names across reboots
+         generate_udev_entry
+      else
+         remauto
+      fi
       IFACEDONE="DONE"
     fi
   done