Delete-obsolete-files: NEWS, TODO, lilo.changelogs
[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         if test -f /etc/kernel/postinst.d/zz-lilo; then
48                 rm -f /etc/kernel/postinst.d/zz-lilo; fi
49         if test -f /etc/kernel/postrm.d/zz-lilo; then
50                 rm -f /etc/kernel/postrm.d/zz-lilo; fi
51         if test -f /etc/initramfs/post-update.d/lilo; then
52                 rm -f /etc/initramfs/post-update.d/lilo; fi
53
54         # Nasty part to create network block devices if needed. Bug#235805.
55         if [ `uname -r | sed -e 's/-.*//g' -ne 's/\(^[0-9]\{1\}\.[0-9]\{1,2\}\).*/\1/p'` = "2.6" ] && \
56            [ `uname -r | sed -e 's/-.*//g' -ne 's/.*\.\([0-9]\{1,3\}\).*/\1/p'` -ge "3" ]; then
57
58           garbage=$(cat /proc/partitions | sed -ne 's/^[ \t]*//pg' | sed -ne '/^43/p')
59
60           if [ x"$garbage" != "x" ]; then
61                 # Create the missing devices
62                 echo -n "Creating network block devices... "
63                 (cd /dev; ./MAKEDEV nb) > /dev/null
64                 echo "done."  
65           fi
66         fi
67
68         db_get lilo/add_large_memory || true;
69         if [ x"$RET" = x"true" -a -e /etc/lilo.conf ]; then
70                 if ! grep -q "^[[:space:]]*large-memory" /etc/lilo.conf; then
71                         sed -i -e '1i\# Automatically added by lilo postinst script\nlarge-memory\n' /etc/lilo.conf
72                         echo "WARNING: Added option 'large-memory', please run 'lilo' before you reboot."
73                 fi
74         fi
75
76         db_get lilo/diskid_uuid || true;
77         if [ x"$RET" = x"true" -a -e /etc/lilo.conf ]; then
78                 if [ `grep -c -E "dev/disk/by-|UUID=" /etc/lilo.conf` -lt 2 ]; then
79                   if test -x /usr/sbin/lilo-uuid-diskid; then
80                     lilo-uuid-diskid
81                     echo "WARNING: If boot / root options were converted, please run 'lilo' before you reboot."
82                   fi
83                 fi
84         fi
85
86         db_get lilo/runme || true;
87         if [ x"$RET" = x"true" ]; then
88                 echo "Running lilo..."
89                 lilo -H
90         fi
91
92         ;;
93         abort-upgrade|abort-remove|abort-deconfigure)
94         ;;
95
96         *)
97                 echo "postinst called with unknown argument \`$1'" >&2
98                 exit 1
99         ;;
100 esac
101
102 # dh_installdeb will replace this with shell code automatically
103 # generated by other debhelper scripts.
104
105 #DEBHELPER#
106
107 exit 0