+echo -n " grub2"
+
+# workaround grsec
+if uname -a | grep -q grsec; then
+ if [ -x /sbin/chpax ]; then
+ # grub
+ if [ -x /usr/sbin/grub.real ]; then
+ chpax -spmrx /usr/sbin/grub.real >/dev/null 2>&1 || true
+ elif [ -x /usr/sbin/grub ]; then
+ chpax -spmrx /usr/sbin/grub >/dev/null 2>&1 || true
+ fi
+
+ # grub-probe
+ if [ -x /usr/sbin/grub-probe.real ]; then
+ chpax -spmrx /usr/sbin/grub-probe.real >/dev/null 2>&1 || true
+ elif [ -x /usr/sbin/grub-probe ]; then
+ chpax -spmrx /usr/sbin/grub-probe >/dev/null 2>&1 || true
+ fi
+
+ echo -n " grsec"
+ fi
+fi
+
+# remove obsolete devfs/compat links and restore normal udev behaviour
+rm -f /etc/udev/rules.d/devfs.rules /etc/udev/rules.d/compat.rules \
+ /etc/udev/rules.d/compat-full.rules
+#if [ ! -e /etc/udev/rules.d/udev.rules ]; then
+# ln -s ../udev.rules /etc/udev/rules.d/udev.rules
+#fi
+udevadm control --reload_rules >/dev/null 2>&1 || true
+udevsettle || true
+echo -n " udev"
+
+# update device map if possible
+if [ -f "$device_map" ]; then
+ mv -f "$device_map" "$device_map.old"
+fi
+grub --batch --no-floppy --device-map="$device_map" <<EOF >/dev/null 2>&1
+quit
+EOF
+if [ ! -s "$device_map" ]; then
+ if [ -f "$device_map.old" ]; then
+ mv -f "$device_map.old" "$device_map"
+ fi
+
+else
+ rm -f "$device_map.old"
+fi
+echo -n " grub3"
+
+# import GRUB helper functions (again, updated device map)
+. /usr/share/kernel-2.6-cn/grub-functions.sh
+
+# get install device (0x80 BIOS device)
+install_device=$(grep '^(hd0)' "$device_map" | \
+ sed -e 's%[^[:space:]]*[[:space:]]*\([^[:space:]]*\)%\1%')
+if [ -z "$install_device" ]; then
+ echo "."
+ echo "CN: FATAL ERROR while detecting boot disk!"
+ echo "CN: Do not reboot your server and report this to OTRS immediately!"
+ exit 1
+fi
+
+# oops, install device is a symlink...
+if [ -h "$install_device" ]; then
+ install_device_resolved=$(resolve_symlink "$install_device")
+ if [ -z "$install_device_resolved" ]; then
+ install_device_resolved="$install_device"
+ fi