Update of debconf files for use of new menu bitmaps
[rrq/maintain_lilo.git] / debian / lilo.postinst
1 #!/bin/sh
2 # postinst script lilo
3 #
4 # see: dh_installdeb(1)
5
6 set -e
7
8 LNKS="sarge sid"
9
10 if [ -f /usr/share/debconf/confmodule ]; then
11   . /usr/share/debconf/confmodule
12 fi
13
14 # targets: configure|abort-upgrade|abort-remove|abort-deconfigure
15
16 case "$1" in
17     configure|reconfigure)
18     
19         # if a new install then we create the link and exit
20         if grep -q "^# UNCONFIGURED FSTAB FOR BASE SYSTEM" /etc/fstab ; then
21           exit 0
22         fi
23
24         # Check whether /boot is on another partition and mount it. See Bug#216250
25         if grep "[[:space:]]/boot[[:space:]]" /etc/fstab | grep -vq "^#"; then
26            if ! grep -q "[[:space:]]/boot[[:space:]]" /etc/mtab ; then
27                 mount /boot 2>&1 > /dev/null
28
29                 if [ $? -ne 0 ]; then
30                         echo
31                         echo "WARNING: /boot is in another partition but could not be mounted."
32                         echo "LILO may fail in the next steps!"
33                 fi
34            fi
35         fi
36
37         # copy all background images to the right place
38         if [ -L /boot/debian.bmp ]; then
39                 rm -f /boot/debian.bmp; fi
40
41         install -m 0644  /usr/share/lilo/*.bmp  /boot
42         # stay compatible with old lilo 22.8
43         for i in ${LNKS}; do
44                 ln -s debian.bmp /boot/${i}.bmp
45         done
46
47         # remove scripts of old lilo 22.8 if still exist
48         if test -f /etc/kernel/postinst.d/zz-lilo; then
49                 rm -f /etc/kernel/postinst.d/zz-lilo; fi
50         if test -f /etc/kernel/postrm.d/zz-lilo; then
51                 rm -f /etc/kernel/postrm.d/zz-lilo; fi
52         if test -f /etc/initramfs/post-update.d/lilo; then
53                 rm -f /etc/initramfs/post-update.d/lilo; fi
54
55         # Nasty part to create network block devices if needed. Bug#235805.
56         if [ `uname -r | sed -e 's/-.*//g' -ne 's/\(^[0-9]\{1\}\.[0-9]\{1,2\}\).*/\1/p'` = "2.6" ] && \
57            [ `uname -r | sed -e 's/-.*//g' -ne 's/.*\.\([0-9]\{1,3\}\).*/\1/p'` -ge "3" ]; then
58
59           garbage=$(cat /proc/partitions | sed -ne 's/^[ \t]*//pg' | sed -ne '/^43/p')
60
61           if [ x"$garbage" != "x" ]; then
62                 # Create the missing devices
63                 echo -n "Creating network block devices... "
64                 (cd /dev; ./MAKEDEV nb) > /dev/null
65                 echo "done."  
66           fi
67         fi
68
69         db_get lilo/add_large_memory || true;
70         if [ x"$RET" = x"true" -a -e /etc/lilo.conf ]; then
71                 if ! grep -q "^[[:space:]]*large-memory" /etc/lilo.conf; then
72                         sed -i -e '1i\# Automatically added by lilo postinst script\nlarge-memory\n' /etc/lilo.conf
73                         echo "WARNING: Added option 'large-memory', please run 'lilo' before you reboot."
74                 fi
75         fi
76
77         db_get lilo/diskid_uuid || true;
78         if [ x"$RET" = x"true" -a -e /etc/lilo.conf ]; then
79                 if [ `grep -c -E "dev/disk/by-|UUID=" /etc/lilo.conf` -lt 2 ]; then
80                   if test -x /usr/sbin/lilo-uuid-diskid; then
81                     lilo-uuid-diskid
82                     echo "WARNING: If boot / root options were converted, please run 'lilo' before you reboot."
83                   fi
84                 fi
85         fi
86
87         db_get lilo/runme || true;
88         if [ x"$RET" = x"true" ]; then
89                 echo "Running lilo..."
90                 lilo -H
91         fi
92
93         ;;
94         abort-upgrade|abort-remove|abort-deconfigure)
95         ;;
96
97         *)
98                 echo "postinst called with unknown argument \`$1'" >&2
99                 exit 1
100         ;;
101 esac
102
103 # dh_installdeb will replace this with shell code automatically
104 # generated by other debhelper scripts.
105
106 #DEBHELPER#
107
108 exit 0