verify.func 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. if [ "$SRC" != "" ]
  2. then
  3. set -A tokens $SRC
  4. if [ "${tokens[3]}" = "file" ]
  5. then
  6. if [ -f ${tokens[0]} ]
  7. then
  8. printf "exists "
  9. else
  10. printf "MISSING or REMOVED "
  11. echo "${tokens[0]}"
  12. continue
  13. fi
  14. elif [ "${tokens[3]}" = "sym_link" ]
  15. then
  16. if [ -L ${tokens[0]} ]
  17. then
  18. printf "exists "
  19. else
  20. printf "MISSING or REMOVED "
  21. echo "${tokens[0]}"
  22. continue
  23. fi
  24. fi
  25. if [ "${tokens[3]}" = "file" ]
  26. then
  27. touch /tmp/config-test
  28. chmod ${tokens[1]} /tmp/config-test
  29. tmpperms=`ls -l /tmp/config-test | awk '{print $1}'`
  30. realperms=`ls -l ${tokens[0]} | awk '{print $1}'`
  31. if [ "$tmpperms" = "$realperms" ]
  32. then
  33. printf "correct "
  34. else
  35. printf " WRONG "
  36. fi
  37. owner=`ls -l ${tokens[0]} | awk '{print $3}'`
  38. if [ "$owner" = "${tokens[4]}" ]
  39. then
  40. printf "correct "
  41. else
  42. printf " WRONG "
  43. fi
  44. group=`ls -l ${tokens[0]} | awk '{print $4}'`
  45. if [ "$group" = "${tokens[5]}" ]
  46. then
  47. printf "correct "
  48. else
  49. printf " WRONG "
  50. fi
  51. elif [ "${tokens[3]}" = "sym_link" ]
  52. then
  53. linkto=`ls -l ${tokens[0]} | awk '{print $11}'`
  54. if [ "${tokens[2]}" = "$linkto" ]
  55. then
  56. printf " the link is correct "
  57. else
  58. printf " the link is WRONG "
  59. fi
  60. fi
  61. echo "${tokens[0]}"
  62. fi