Fix command redirection in postinst script
[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 if [ -f /usr/share/debconf/confmodule ]; then
9   . /usr/share/debconf/confmodule
10 fi
11
12 # remove old-named config files
13 dpkg-maintscript-helper rm_conffile \
14   /etc/kernel/postinst.d/zz-lilo  1:22.8-10 lilo -- "$@"
15
16 dpkg-maintscript-helper rm_conffile \
17   /etc/kernel/postrm.d/zz-lilo    1:22.8-10 lilo -- "$@"
18
19 dpkg-maintscript-helper rm_conffile \
20   /etc/kernel/postinst.d/zz-lilo  1:22.8-10 lilo -- "$@"
21
22 dpkg-maintscript-helper rm_conffile \
23   /etc/initramfs/post-update.d/lilo  1:22.8-10 lilo -- "$@"
24
25
26 # targets: configure|abort-upgrade|abort-remove|abort-deconfigure
27
28 case "$1" in
29     configure|reconfigure)
30     
31         # if a new install then we create the link and exit
32         if grep -q "^# UNCONFIGURED FSTAB FOR BASE SYSTEM" /etc/fstab ; then
33           exit 0
34         fi
35
36         # Check whether /boot is on another partition and mount it. See Bug#216250
37         if grep "[[:space:]]/boot[[:space:]]" /etc/fstab | grep -vq "^#"; then
38            if ! grep -q "[[:space:]]/boot[[:space:]]" /etc/mtab ; then
39                 mount /boot  > /dev/null 2>&1
40
41                 if [ $? -ne 0 ]; then
42                         echo
43                         echo "WARNING: /boot is in another partition but could not be mounted."
44                         echo "LILO may fail in the next steps!"
45                 fi
46            fi
47         fi
48
49         # copy all background images to the right place
50         if [ -L /boot/debian.bmp ]; then
51                 rm -f /boot/debian.bmp; fi
52
53         install -m 0644  /usr/share/lilo/*.bmp  /boot
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