Improve /etc/grml/fai/live-initramfs/live.conf handling
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 10-build-initramfs
1 #!/bin/sh
2 # Filename:      /etc/grml/fai/config/scripts/GRMLBASE/10-build-initramfs
3 # Purpose:       configure live-initramfs and build initramfs for booting
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@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 -e
10
11 if ! [ -f "$target/etc/live.conf" ] ; then
12   echo "Warning: $target/etc/live.conf does not exist yet,"
13   echo "         ... installing /etc/grml/fai/live-initramfs/live.conf"
14   cp /etc/grml/fai/live-initramfs/live.conf "$target/etc/live.conf"
15 fi
16
17 if [ -f /etc/grml/fai/live-initramfs/grml-script.init-top ] ; then
18   cp /etc/grml/fai/live-initramfs/grml-script.init-top "$target/usr/share/initramfs-tools/scripts/init-top/grml"
19 else
20   echo "Warning: /etc/grml/fai/live-initramfs/grml-script.init-top could not be read"
21 fi
22
23 FILE=$(ls -1 $target/boot/vmlinuz-* 2>/dev/null| sort -r | head -1)
24 KERNELVERSION=$(echo "${FILE##$target/boot/vmlinuz-}")
25
26 # make sure mdadm isn't executed in initrd:
27 #if [ -f "$target"/etc/default/mdadm ] ; then
28 #   sed -i "s/START_DAEMON=.*/START_DAEMON=false/" "$target"/etc/default/mdadm
29 #   sed -i "s/INITRDSTART=.*/INITRDSTART=none/"    "$target"/etc/default/mdadm
30 #fi
31
32 if [ -z "$KERNELVERSION" ] ; then
33    echo "Error: No kernel found, can not create initramfs. Exiting.">&2
34    exit 1
35 fi
36
37 if [ -f $target/usr/share/initramfs-tools/scripts/live ] ; then
38    $ROOTCMD update-initramfs -c -t -k $KERNELVERSION
39 else
40    echo "Error: live-initramfs does not seem to be present, can not create initramfs. Exiting.">&2
41    exit 1
42 fi
43
44 ## END OF FILE #################################################################
45 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3