Merge initramfs scripts
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 80-initramfs
diff --git a/etc/grml/fai/config/scripts/GRMLBASE/80-initramfs b/etc/grml/fai/config/scripts/GRMLBASE/80-initramfs
new file mode 100755 (executable)
index 0000000..b2b0879
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+# Filename:      ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/80-initramfs
+# Purpose:       configure initramfs and rebuild it
+# Authors:       grml-team (grml.org)
+# Bug-Reports:   see http://grml.org/bugs/
+# License:       This file is licensed under the GPL v2 or any later version.
+################################################################################
+
+set -u
+set -e
+
+fcopy -v /etc/initramfs-tools/hooks/000-udev-shutup
+fcopy -v /etc/initramfs-tools/conf.d/xz-compress
+
+if ! [ -f $target/usr/share/initramfs-tools/scripts/live ] ; then
+  echo "Error: live-boot/-initramfs does not seem to be present, can not create initramfs. Exiting.">&2
+  exit 1
+fi
+
+echo "Rebuilding initramfs"
+
+for initrd in "$(basename $target/boot/vmlinuz-*)" ; do
+    if ! $ROOTCMD update-initramfs -k "${initrd##vmlinuz-}" -c ; then
+        echo "Creating fresh initrd did not work, trying update instead:"
+        $ROOTCMD update-initramfs -k "${initrd##vmlinuz-}" -u
+    fi
+done