c7b2016708c0f4c22eeab8bf44df42bb63c6427c
[grml-rescueboot.git] / 42_grml
1 #!/bin/sh
2 # Filename:      42_grml
3 # Purpose:       grub-mkconfig helper script for Grml rescue systems
4 # Authors:       grml-team (grml.org), (c) Andreas Gredler <jimmy@grml.org>, Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2+.
7 ################################################################################
8
9 set -e
10
11 prefix=/usr
12 exec_prefix=${prefix}
13 bindir=${exec_prefix}/bin
14 libdir=${exec_prefix}/lib
15 . ${libdir}/grub/grub-mkconfig_lib
16
17 # default unless configured otherwise:
18 ISO_LOCATION="/boot/grml"
19
20 if [ -r /etc/default/grml-rescueboot ] ; then
21   . /etc/default/grml-rescueboot
22 fi
23
24 iso_list=""
25 for file in "${ISO_LOCATION}"/*.iso ; do
26      if grub_file_is_not_garbage "$file" ; then
27        iso_list="$iso_list $file "
28      fi
29 done
30
31 for grmliso in $iso_list ; do
32   rel_dirname="$(make_system_path_relative_to_its_root $(dirname $grmliso))"
33   grml="$(basename $grmliso)"
34   device="$(${grub_probe} -t device ${grmliso})"
35
36   additional_param=""
37
38   case "$device" in
39       /dev/mapper*|/dev/md*)
40       additional_param="live-media=$device"
41       ;;
42   esac
43
44   echo "Found Grml ISO image: $grmliso" >&2
45   title="Grml Rescue System ($grml)"
46
47   cat << EOF
48 menuentry "${title}" {
49 $(prepare_grub_to_access_device "$device" | sed -e "s/^/        /")
50         iso_path="${rel_dirname}/${grml}"
51         export iso_path
52         kernelopts="$CUSTOM_BOOTOPTIONS $additional_param"
53         export kernelopts
54         loopback loop "${rel_dirname}/$grml"
55         set root=(loop)
56         configfile /boot/grub/loopback.cfg
57 }
58 EOF
59 done
60
61 ## END OF FILE #################################################################