Create specific netboot initramfs file (WIP)
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 80-initramfs
1 #!/bin/sh
2 # Filename:      ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/80-initramfs
3 # Purpose:       configure initramfs and rebuild it
4 # Authors:       grml-team (grml.org)
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2 or any later version.
7 ################################################################################
8
9 set -u
10 set -e
11
12 fcopy -v /etc/initramfs-tools/hooks/000-udev-shutup
13 fcopy -v /etc/initramfs-tools/conf.d/xz-compress
14
15 # used for grml-live's netboot package
16 fcopy -i -B -v -r /etc/grml-netboot
17
18 if ! [ -f $target/usr/share/initramfs-tools/scripts/live ] ; then
19   echo "Error: live-boot/-initramfs does not seem to be present, can not create initramfs. Exiting.">&2
20   exit 1
21 fi
22
23 echo "Rebuilding initramfs"
24
25 for initrd in "$(basename $target/boot/vmlinuz-*)" ; do
26   if ! $ROOTCMD update-initramfs -k "${initrd##vmlinuz-}" -c ; then
27     echo "Creating fresh initramfs did not work, trying update instead:"
28     $ROOTCMD update-initramfs -k "${initrd##vmlinuz-}" -u
29   fi
30
31   # write it to /grml-live/, as we ignore that directory via
32   # /etc/grml/fai/config/grml/squashfs-excludes, to
33   # not include the file into the ISO itself, but have
34   # it available for netboot package usage
35   if [ -d "${target}"/etc/grml-netboot ] ; then
36     echo "Creating netboot initrd file (/grml-live/netboot.initrd)"
37     $ROOTCMD mkinitramfs -d /etc/grml-netboot -o /grml-live/netboot.initrd -k "${initrd##vmlinuz-}"
38   else
39     echo "Warning: /etc/grml-netboot doesn't exist, skipping netboot initrd generation."
40   fi
41 done