有时从源更新内核后grub的配置文件有点问题造成重启后无法启动。尤其是远程更新重启后比较麻烦。写了个脚本可以检测grub2的配置文件
- #!/bin/bash
-
end="\e[0m"
-
red="\e[1;31;40m"
-
ver="\e[1;32;40m"
-
yel="\e[1;33;40m"
-
blu="\e[1;34;40m"
-
pur="\e[1;35;40m"
-
gre="\e[1;36;40m"
-
whi="\e[1;37;40m"
-
filein=/boot/grub/grub.cfg
-
fileout=/var/tmp/$$.list
-
echo -e "${pur}checking the kernel image file${end}"
-
grep "vmlinuz" $filein|awk '{print $2}'|uniq >$fileout
-
grep "initrd" $filein|awk '{print $2}'|uniq >>$fileout
-
cat $fileout
-
echo -e "${pur}test the image file${end}"
-
error=0
-
while read i
-
do
-
if [ ! -s $i ];
-
then
-
printf "error! can't find $red%s$end\n" $i
-
error=$((++error))
-
fi
-
done <$fileout
-
rm -rf $fileout
-
if [ $error -gt 0 ]
-
then
-
echo -e "there is some wrong with the file:" $yel$filein$end
-
else
-
echo -e "${blu}OK,all is good!${end}"
-
fi
阅读(2651) | 评论(2) | 转发(1) |