#!/bin/bash # checks if GRUB1 boot configuration is valid (not compatible with GRUB2!) # intended for my headless server # # source by .bashrc would be possible but not recommended as you'd be spawning a lot of processes. BASEDIR=/boot #no trailing slash oldIFS=$IFS IFS=" " # TODO: Check if disk path is root # TODO: Check if kernel file's uname has modules installed if [ ! -f ${BASEDIR}/grub/menu.lst ]; then echo "BOOTCHECK: Menu.lst isn't available! Is /boot mounted?" exit 1 else KERNEL=(`egrep '^kernel.*' ${BASEDIR}/grub/menu.lst`) INITRD=(`egrep '^initrd.*' ${BASEDIR}/grub/menu.lst`) KERNELFILE="${BASEDIR}${KERNEL[1]}" DISKPATH=`echo ${KERNEL[2]} | cut -c6-` INITRDFILE="${BASEDIR}${INITRD[1]}" if [ ! -e "$KERNELFILE" ]; then echo "BOOTCHECK: $KERNELFILE does not exist" # kernel file exit 1 elif [ ! -e $DISKPATH ]; then echo "BOOTCHECK: $DISKPATH does not exist!!!" # disk path exit 1 elif [ ! -e $INITRDFILE ]; then echo "BOOTCHECK: $INITRDFILE does not exist" # initrd file exit 1 fi fi IFS=$oldIFS exit 0