2
0

build_summary_cron 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #!/bin/ksh
  2. #
  3. # build_summary_cron
  4. #
  5. ########################################################################
  6. #set -x
  7. ##########################################################################
  8. #
  9. # Script setup: THIS NEEDS TO BE FIRST
  10. #
  11. SCRIPTS_DIR="`dirname $0`"
  12. PROG_NAME="`basename $0`"
  13. if [ "" = "$SCRIPTS_DIR" ]; then
  14. SCRIPTS_DIR=/project/dt/scripts
  15. fi
  16. if [ ! -f $SCRIPTS_DIR/script_setup.ksh ]; then
  17. print -u2 "$PRG: File '$SCRIPTS_DIR/script_setup.ksh' NOT found!"
  18. print -u2 "$PRG: Exiting ..."
  19. exit 1
  20. fi
  21. . $SCRIPTS_DIR/script_setup.ksh
  22. ##########################################################################
  23. ##########################################################################
  24. #
  25. # Script specific global variables
  26. #
  27. ##########################################################################
  28. ##########################################################################
  29. BUILD_SUMMARY_ARGS=""
  30. DEBUG="False"
  31. MAIL_LIST=""
  32. let RETRIES=4
  33. let SLEEP_SECONDS=3600
  34. let REPORT_NUM=1
  35. usage ()
  36. {
  37. cat <<eof
  38. USAGE: $PROG_NAME
  39. [-retries <#_retries>]
  40. [-sleep <#_seconds>]
  41. [-h | -? | -help]
  42. # Print usage and exit
  43. #
  44. # '$PROG_NAME' calls 'build_summary' to construct the report.
  45. #
  46. # If 'build_summary' returns an error code indicating
  47. # that some of the specified builds have not completed,
  48. # '$PROG_NAME' will put itself to sleep for 3600 seconds
  49. # before trying again up to a maximum of 4 times.
  50. # The number of retries and the sleep time can be altered
  51. # using the '-retries' and '-sleep' options.
  52. #
  53. # Any command-line options not recognized by '$PROG_NAME' are
  54. # passed to 'build_summary'.
  55. #
  56. # Any output from 'build_summary' is passed to the users
  57. # specified in the '-mail' option.
  58. eof
  59. }
  60. #
  61. # Do command-line processing
  62. #
  63. while [ $# -gt 0 ]; do
  64. case $1 in
  65. -debug)
  66. DEBUG="True"
  67. shift ;;
  68. -h | -help | '-?')
  69. usage $PROG_NAME
  70. do_exit 1 ;;
  71. -retries)
  72. if [ $# -lt 2 ]; then
  73. print -u2 "$PROG_NAME: $1 option missing value; exiting ..."
  74. do_exit 1
  75. fi
  76. let RETRIES=$2
  77. shift 2 ;;
  78. -sleep)
  79. if [ $# -lt 2 ]; then
  80. print -u2 "$PROG_NAME: $1 option missing value; exiting ..."
  81. do_exit 1
  82. fi
  83. let SLEEP_SECONDS=$2
  84. shift 2 ;;
  85. *)
  86. BUILD_SUMMARY_ARGS="$BUILD_SUMMARY_ARGS $1"
  87. shift 1 ;;
  88. esac
  89. done
  90. while [[ $RETRIES -ge 0 ]]
  91. do
  92. $BUILD_SUMMARY $BUILD_SUMMARY_ARGS
  93. STATUS=$?
  94. if [ $STATUS -eq 0 ]; then
  95. #
  96. # Clean up temporary files and exit
  97. #
  98. do_exit 0
  99. fi
  100. let REPORT_NUM=REPORT_NUM+1
  101. let RETRIES=RETRIES-1
  102. if [[ $RETRIES -ge 0 ]]; then
  103. sleep $SLEEP_SECONDS
  104. fi
  105. done
  106. #
  107. # Clean up temporary files and exit
  108. #
  109. do_exit 1