check-grub-mode.sh 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. MODE=$(ls -l /boot/grub/grub.cfg | awk '{print $1}')
  3. if [ "$(printf "%c" "$MODE")" == "-" ];then #First char at MODE(----------)
  4. :
  5. else
  6. exit 1
  7. fi
  8. TEMP=${MODE#?} #remove first char at MODE and save at $TEMP
  9. printf "%c" "$TEMP" | grep -w "^r$\|^-$"
  10. if [ $? -eq 0 ];then
  11. :
  12. else
  13. exit 1
  14. fi
  15. TEMP=${TEMP#?}
  16. printf "%c" "$TEMP" | grep -w "^w$\|^-$"
  17. if [ $? -eq 0 ];then
  18. :
  19. else
  20. exit 1
  21. fi
  22. TEMP=${TEMP#?}
  23. printf "%c" "$TEMP" | grep -w "^-$"
  24. if [ $? -eq 0 ];then
  25. :
  26. else
  27. exit 1
  28. fi
  29. TEMP=${TEMP#?}
  30. printf "%c" "$TEMP" | grep -w "^-$"
  31. if [ $? -eq 0 ];then
  32. :
  33. else
  34. exit 1
  35. fi
  36. TEMP=${TEMP#?}
  37. printf "%c" "$TEMP" | grep -w "^-$"
  38. if [ $? -eq 0 ];then
  39. :
  40. else
  41. exit 1
  42. fi
  43. TEMP=${TEMP#?}
  44. printf "%c" "$TEMP" | grep -w "^-$"
  45. if [ $? -eq 0 ];then
  46. :
  47. else
  48. exit 1
  49. fi
  50. TEMP=${TEMP#?}
  51. printf "%c" "$TEMP" | grep -w "^-$"
  52. if [ $? -eq 0 ];then
  53. :
  54. else
  55. exit 1
  56. fi
  57. TEMP=${TEMP#?}
  58. printf "%c" "$TEMP" | grep -w "^-$"
  59. if [ $? -eq 0 ];then
  60. :
  61. else
  62. exit 1
  63. fi
  64. TEMP=${TEMP#?}
  65. printf "%c" "$TEMP" | grep -w "^-$"
  66. if [ $? -eq 0 ];then
  67. :
  68. else
  69. exit 1
  70. fi