Add lilo-uuid-diskid script with manpage
[rrq/maintain_lilo.git] / debian / lilo.postinst
1 #!/bin/sh 
2
3 set -e
4
5 if [ -f /usr/share/debconf/confmodule ]; then
6   . /usr/share/debconf/confmodule
7 fi
8
9 #DEBHELPER#
10 case "$1" in
11     configure|reconfigure)
12     
13         # if a new install then we create the link and exit
14         if grep -q "^# UNCONFIGURED FSTAB FOR BASE SYSTEM" /etc/fstab ; then
15           exit 0
16         fi
17
18         # Check whether /boot is on another partition and mount it. See Bug#216250
19
20         if grep "[[:space:]]/boot[[:space:]]" /etc/fstab | grep -vq ^#; then
21            if ! grep -q "[[:space:]]/boot[[:space:]]" /etc/mtab ; then
22                 mount /boot 2>&1 > /dev/null
23
24                 if [ $? -ne 0 ]; then
25                         echo
26                         echo "WARNING: /boot is in another partition but could not be mounted."
27                         echo "LILO may fail in the next steps."
28                 fi
29            fi
30         fi
31
32         cp /usr/share/lilo/*.bmp /boot
33         
34         if [ -L /boot/debian.bmp ]; then
35                 if [ x`readlink /boot/debian.bmp | cut -d/ -f 2` != x"boot" ]; then
36                         ln -sf /boot/sid.bmp /boot/debian.bmp
37                 fi
38         fi
39
40         if [ ! -e /boot/debian.bmp ]; then
41                 ln -sf /boot/sarge.bmp /boot/debian.bmp
42         fi
43
44         # Nasty part to create network block devices if needed. Bug#235805.
45         if [ `uname -r | sed -e 's/-.*//g' -ne 's/\(^[0-9]\{1\}\.[0-9]\{1,2\}\).*/\1/p'` = "2.6" ] && \
46            [ `uname -r | sed -e 's/-.*//g' -ne 's/.*\.\([0-9]\{1,3\}\).*/\1/p'` -ge "3" ]; then
47
48            garbage=$(cat /proc/partitions | sed -ne 's/^[ \t]*//pg' | sed -ne '/^43/p')
49
50            if [ x"$garbage" != "x" ]; then
51                 
52                 # Create the missing devices
53                 echo -n "Creating network block devices... "
54                 (cd /dev; ./MAKEDEV nb) > /dev/null
55                 echo "done."  
56             fi
57         fi
58
59         db_get lilo/add_large_memory || true;
60         if [ x"$RET" = x"true" -a -e /etc/lilo.conf ]; then
61                 if ! grep -q "^[[:space:]]*large-memory" /etc/lilo.conf; then
62                         sed -i -e '1i\# Automatically added by lilo postinst script\nlarge-memory\n' /etc/lilo.conf
63                         echo "WARNING: Added large-memory option, please run lilo before you reboot"
64                 fi
65         elif [ -e /vmlinuz -a -e /initrd.img -a -e /etc/lilo.conf ]; then
66                 kernel_size=$(stat -L -c %s /vmlinuz)
67                 initrd_size=$(stat -L -c %s /initrd.img)
68                 size=$(($kernel_size+$initrd_size))
69                 large_mem=$(grep -c "^[[:space:]]*large-memory" /etc/lilo.conf) || true
70                 if [ $large_mem -eq 0 -a $size -ge 8388608 ]; then
71                         echo
72                         echo "WARNING: You have a large kernel+initrd and large-memory is not set in lilo.conf."
73                         echo "WARNING: Do NOT reboot or LILO may fail to boot."
74                         echo "WARNING: Please read /usr/share/doc/lilo/README.Debian"
75                         echo 
76                 fi
77         else
78                 echo
79                 echo "WARNING: kernel & initrd not found in the root directory (/vmlinuz & /initrd.img)"
80                 echo "WARNING: Do NOT reboot or LILO may fail to boot if your kernel+initrd is large."
81                 echo "WARNING: Please read /usr/share/doc/lilo/README.Debian"
82                 echo
83         fi
84
85         db_get lilo/runme || true;
86         if [ x"$RET" = x"true" ]; then
87                 echo "Running lilo..."
88                 /sbin/lilo -H
89         fi
90
91         ;;
92     abort-upgrade|abort-remove|abort-deconfigure)
93
94         ;;
95
96     *)
97         echo "postinst called with unknown argument \`$1'" >&2
98         exit 1
99         ;;
100 esac
101
102 exit 0