Release new version 0.4.2
[grml-rescueboot.git] / debian / postinst
1 #!/bin/sh
2 # postinst script for grml-rescueboot
3
4 set -e
5
6 update_grub_wrapper() {
7   # default, unless configured otherwise:
8   ISO_LOCATION=/boot/grml
9
10   if [ -r /etc/default/grml-rescueboot ] ; then
11     . /etc/default/grml-rescueboot
12   fi
13
14   if ! ls "${ISO_LOCATION}"/*iso >/dev/null 2>&1 ; then
15     echo "INFO: No *.iso files found inside ${ISO_LOCATION}."
16     echo "INFO: Please create ${ISO_LOCATION} and place rescue ISO(s) there."
17     echo "INFO: Finally invoke update-grub and enjoy your rescue system."
18     return 0
19   fi
20
21   if ! which update-grub >/dev/null 2>&1; then
22     echo "WARN: ISOs found inside ${ISO_LOCATION} but update-grub not present (huh?)"
23     return 0
24   fi
25
26   if ! [ -e /boot/grub/grub.cfg ] ; then
27     echo "WARN: ISOs found inside ${ISO_LOCATION} but /boot/grub/grub.cfg does not exist."
28     echo "WARN: Ignoring request to run update-grub to avoid possible boot loader problems."
29     return 0
30   fi
31
32   echo "INFO: ISOs found inside ${ISO_LOCATION}, invoking update-grub:"
33   update-grub
34 }
35
36 case "$1" in
37     configure)
38       update_grub_wrapper
39     ;;
40
41     abort-upgrade|abort-remove|abort-deconfigure)
42     ;;
43
44     *)
45         echo "postinst called with unknown argument \`$1'" >&2
46         exit 1
47     ;;
48 esac
49
50 #DEBHELPER#
51
52 exit 0