#!/bin/bash BOOT_DEV="$(grep " / " /etc/fstab)" BOOT_DEV="${BOOT_DEV%%[0-9] *}" GRUB=$'(file -s $BOOT_DEV |grep "GRand Unified Bootloader")' LILO=$'(file -s $BOOT_DEV |grep "LInux i386 boot LOader")' if [ $"LILO" ] ; then lilo -R poweroff reboot exit else if [ $"GRUB" ] ; then REBOOT_LINE=$(grep -s ^title /boot/grub/grub.conf |grep -i -n poweroff | { IFS=: read a b ; echo $a ; }) grub-set-default $((REBOOT_LINE-1)) reboot exit fi fi