checkinst 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # Display functions
  3. function check_out
  4. {
  5. echo "[checkinst] $1"
  6. }
  7. function check_fatal
  8. {
  9. check_out "FATAL : $1"
  10. }
  11. # Variables
  12. out_target='/usr/local/bin/'
  13. in_source='./'
  14. # Process arguments
  15. while [ $# -gt 0 ]
  16. do
  17. case $1 in
  18. '--help' | '-h')
  19. check_out "usage : $0 [options]"
  20. check_out 'Used to check if newer scripts are available.'
  21. check_out '-h | --help : display this help'
  22. check_out '-o | --out <directory> : current local installed scripts directory'
  23. check_out '-i | --in <directory> : available newer scripts'
  24. ;;
  25. '--out' | '-o')
  26. out_target=$2
  27. shift
  28. check_out "set output directory to $out_target"
  29. ;;
  30. '--in' | '-i')
  31. in_source=$2
  32. shift
  33. check_out "set input directory to $in_source"
  34. ;;
  35. *)
  36. check_fatal "unknown argument $1"
  37. ;;
  38. esac
  39. shift
  40. done
  41. # Check installation
  42. check_out "Checking newer scripts from $in_source to $out_target"
  43. for sc in `ls $in_source`
  44. do
  45. if [ ! -e "$out_target$sc" ]
  46. then
  47. check_out "x - not installed : $sc"
  48. elif [ "$in_source$sc" -nt "$out_target$sc" ]
  49. then
  50. check_out "+ - can be updated : $sc"
  51. fi
  52. done
  53. # End
  54. check_out 'Done.'
  55. exit $?