+# 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."
+
+################################################################################
+
+DIVERT_TO="grub grub-probe"
+
+echo -n "CN: Undiverting binaries if necessary:"
+for i in $DIVERT_TO; do
+ if [ -e /usr/sbin/$i.real ]; then
+ dpkg-divert --remove --rename --package 'kernel-2.6-cn' \
+ --divert /usr/sbin/$i.real /usr/sbin/$i >/dev/null
+ echo -n " $i"
+ fi
+done
+echo "."
+
+################################################################################
+
+# detect existing Grub2 installation
+
+GRUB2="no"
+if [ -e /boot/grub/grub.cfg ];
+ echo "CN: Detected GRUB2 installation, will try to use it."
+ GRUB2="yes"
+ if [ -e /boot/grub/menu.lst ]; then
+ echo "CN: Oops, GRUB1 (Legacy) installation detected. Will try to upgrade to GRUB2."
+ fi
+else
+ echo "CN: No GRUB2 detected, will continue with GRUB1 as default option."
+fi
+
+################################################################################
+