grml-terminalserver-config: do not rebuild initrd but use the existing one
authorMichael Prokop <mika@grml.org>
Wed, 29 Sep 2010 15:54:54 +0000 (17:54 +0200)
committerMichael Prokop <mika@grml.org>
Wed, 29 Sep 2010 15:54:54 +0000 (17:54 +0200)
Rebuilding the initramfs takes quite long and is tricky and even
error prone. The initramfs we ship with Grml ISOs by default
are supposed to provide whatever it needs for PXE booting, therefore
skip the upgrade-initramfs and use the initrd.gz from the ISO instead.

grml-terminalserver-config

index ff3a40e..2cfae3f 100755 (executable)
@@ -114,58 +114,31 @@ function actionAutoconf
 }
 # }}}
 
-
 # INITRD {{{
 function actionMkInitrd
 {
   echo
-  echo "Creating initrd $PATH_/minirt26.gz:"
+  echo "Installing initrd $PATH_/minirt26.gz:"
   if isExistent "$PATH_/minirt26.gz" ; then
      echo
-     echo "$PATH_/minirt26.gz exists already, skipping initrd creation"
+     echo "$PATH_/minirt26.gz exists already, nothing to do"
      return 0
   fi
 
-  mkInitrd
-
-  echo '... done'
+  # until we have a stable file location API let's use
+  # an according heuristic
+  for file in "$(find /live/image/boot -name initrd.gz)"; do
+    dir="$(dirname $file)"
+    if file "$dir"/linux26 | grep -q "$(uname -r)" ; then
+      cp "$dir"/initrd.gz "$PATH_"/minirt26.gz
+      echo '... done'
+      return 0
+    fi
+  done
 }
 
-function mkInitrd
-{
-  # we do not want to include persistent configuration files
-  # from udev in the initrd
-  udev_tmp_=$(mktemp -d terminalserver__udev.XXXXXX)
-  persistent=false
-  if ls /etc/udev/rules.d/*persistent* >/dev/null 2>&1 ; then
-    persistent_files=true
-    for f in /etc/udev/rules.d/*persistent* ; do
-      mv "$f" "${udev_tmp_}/"
-    done
-  fi
-
-  set -e
-  local cfg_="/etc/initramfs-tools/initramfs.conf"
-  local tmp_="`mktemp -t terminalserver__initramfsbk.XXXXXX`"
-  cp $cfg_ $tmp_
-  sed -i 's/^MODULES=.*/MODULES=netboot/' $cfg_
-  update-initramfs -u -t 1>/dev/null
-  mv $tmp_ $cfg_
-
-  local initrd_="/boot/initrd.img-$KERNEL_VERSION_"
-  mv $initrd_ $PATH_/minirt26.gz
-  mv ${initrd_}.bak $initrd_
-  set +e
-
-  # restore udev configuration files
-  if $persistent_files ; then
-    mv ${udev_tmp_}/* /etc/udev/rules.d/
-    rmdir "${udev_tmp_}"
-  fi
-}
 # }}}
 
-
 # INTERACTIVE CONFIGURATION  {{{
 
 function actionInteractive