- grupa workaroundova oko potrganog groot i kopt parametra na nekim GRUB instalacijam...
[kernel-cn.git] / debian / postinst
index 2974a18..e22b539 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# postinst script for spamassassin-cn
+# postinst script for kernel-2.6-cn
 #
 # see: dh_installdeb(1)
 
@@ -30,6 +30,9 @@ esac
 # import CN-functions
 . /usr/share/carnet-tools/functions.sh
 
+# import GRUB helper functions
+. /usr/share/kernel-2.6-cn/grub-functions.sh
+
 ################################################################################
 
 # starting up backup
@@ -58,6 +61,14 @@ echo "."
 
 ################################################################################
 
+# remove obsolete symlinks and kernels
+rm -f /boot/vmlinuz /boot/vmlinuz.old /boot/vmlinuz.old2 \
+  /boot/vmlinuz.plain /vmlinuz /vmlinuz.old /boot/vmlinuz.plain \
+  /boot/vmlinuz.generic /boot/vmlinuz-generic /boot/vmlinuz-old
+echo "CN: Removed old symlinks in / and /boot."
+
+################################################################################
+
 # intro msg
 echo -n "CN: Configuring system (this will take a while):"
 
@@ -102,6 +113,7 @@ if [ ! -d /boot/grub ]; then
         cp -a /usr/lib/grub/i386-pc/* /boot/grub
     fi
 fi
+echo -n " grub1"
 
 # create/update grub configuration
 if [ -e /boot/grub/menu.lst ]; then
@@ -115,16 +127,18 @@ if [ ! -e /boot/grub/menu.lst ]; then
 else
     /usr/sbin/update-grub >/dev/null 2>&1 || true
 fi
+echo -n " grub2"
 
 # workaround grsec
 if [ -x /sbin/chpax ]; then
-    if [ -x /usr/sbin/grub-install ]; then
-        chpax -ps /usr/sbin/grub-install
+    if [ -x /usr/sbin/grub ]; then
+        chpax -spmrx /usr/sbin/grub || true
     fi
     if [ -x /usr/sbin/grub-probe ]; then
-        chpax -ps /usr/sbin/grub-probe
+        chpax -spmrx /usr/sbin/grub-probe || true
     fi
 fi
+echo -n " grub3"
 
 # workaround execshield
 SHIELD=$(sysctl -e -n kernel.exec-shield)
@@ -139,6 +153,17 @@ if ! grub-install --no-floppy '(hd0)' >/dev/null 2>&1; then
     echo "CN: Do not reboot your server and report this to OTRS immediately!"
     exit 1
 fi
+echo -n " grub4"
+
+# fix possible wrong params in menu.lst
+cp_check_and_sed '^# groot=' \
+  "s;^# groot=.*;# groot=$grub_root_device;g" \
+      /boot/grub/menu.lst || true
+cp_check_and_sed '^# kopt=' \
+  "s;^# kopt=\(.*\)root=[^[:space:]]*\(.*\);# kopt=\1root=$root_device\2;g" \
+      /boot/grub/menu.lst || true
+/usr/sbin/update-grub >/dev/null 2>&1 || true
+echo -n " grub5"
 
 # restore execshield state
 if [ ! -z "$SHIELD" ]; then
@@ -312,13 +337,6 @@ echo "."
 
 ################################################################################
 
-# remove obsolete links
-rm -f /boot/vmlinuz /boot/vmlinuz.old /boot/vmlinuz.old2 \
-  /boot/vmlinuz.plain /vmlinuz /vmlinuz.old /boot/vmlinuz.plain
-echo "CN: Removed old symlinks in / and /boot."
-
-################################################################################
-
 # fix old kernel-2.4-cn postrm
 if [ -e /var/lib/dpkg/info/kernel-2.4-cn.postrm ]; then
     echo "CN: Fixed old kernel-2.4-cn postrm."