Chinaunix首页 | 论坛 | 博客
  • 博客访问: 952431
  • 博文数量: 99
  • 博客积分: 3306
  • 博客等级: 中校
  • 技术积分: 1238
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-21 10:14
文章分类

全部博文(99)

文章存档

2012年(37)

2011年(56)

2010年(6)

分类: Python/Ruby

2011-04-07 20:59:26

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

阅读(2575) | 评论(2) | 转发(1) |
0

上一篇:windows下的GCC

下一篇:Debian安装小记

给主人留下些什么吧!~~

tjpm2011-04-10 21:15:17

freesky3555: CU 也变漂亮了.....
呵呵,新版本的确实好看一点。不过shell代码好像缩进有点问题。

freesky35552011-04-10 20:51:17

CU 也变漂亮了