home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2852 / checkup < prev    next >
Encoding:
Text File  |  1991-02-24  |  7.2 KB  |  287 lines

  1. :
  2. # RNALIB Support Utilities 
  3. # checkup 1.0
  4. #
  5. # Performs a bunch of checks upon the whole RNALIB's
  6. # environment. It will not allow RNALIB to continue processing any
  7. # mail unless specified.
  8. # To let RNA continue its work, a $TMPDIR/status file should be
  9. # created containing "RRUN".
  10. #
  11. # Common variables.
  12. CKLOG="/tmp/chkuplog.$$"
  13. rm -f /tmp/chkuplog.* 2>/dev/null
  14.  
  15. # Common routines.
  16.  
  17. # Check directory and files.
  18. # Returns: nothing if everything is ok.
  19.  
  20. # Initlog
  21. Init_Log() {
  22. >$CKLOG || echo "WARNING: cannot open logfile $CKLOG"
  23. }
  24.  
  25. Stop_Msg() {
  26. echo "\
  27. WARNING\n\
  28. An unrecoverable error was detected inside RNALIB's environment/file system.\n\
  29. RNALIB HAS NOW BEEN STOP BY CREATING \"$RNADIR/stop\";\n\
  30. you need to remove this file by hand in order to let RNALIB run again."
  31.  
  32. }
  33.  
  34. Sig_Msg() {
  35. echo "\n\n\
  36. Sincerely,\n\
  37.               your RNALIB daemon \"checkup\""
  38. }
  39.  
  40.  
  41. Stop_Rna() {
  42. date >$RNADIR/stop
  43. echo "Subject: RNALIB CHECKUP PROBLEMS - STOP\n\n\
  44. `Stop_Msg`\n\nDiagnostic follows:\n`cat $CKLOG`\n`Sig_Msg`" | $MAILER $POSTMASTER
  45. }
  46.  
  47.  
  48. Dir_Chk() {
  49. dir=$1
  50. bad=0
  51. # Is it a null variable? 
  52. test -n "$dir" || { echo "UNDEFINED VARIABLE" >>$CKLOG ; echo ERROR ; return ; }
  53. # Does 'dir' exist?
  54. test -d $dir || { echo "NONEXISTENT DIRECTORY \"$dir\"" >>$CKLOG ; echo ERROR ; return ; }
  55. # All files need to be readable and writable. 
  56. for file in `ls $dir`
  57. do
  58.     test -w $dir/$file || { echo "NO WRITE PERMISSIONS FOR \"$dir/$file\"" >>$CKLOG ; bad=1 ; }
  59.     test -r $dir/$file || { echo "NO READ  PERMISSIONS FOR \"$dir/$file\"" >>$CKLOG ; bad=1 ; }
  60. done
  61. test "$bad" = "1" && echo ERROR
  62.  
  63. }
  64.  
  65. File_RWChk() {
  66. fil=$1
  67. bad=0
  68. # Is it a null variable?
  69. test -n "$fil" || { echo "UNDEFINED VARIABLE" >>$CKLOG ; echo ERROR ; return ; }
  70. # Check file's permissions
  71.     test -w $fil || { echo "NO WRITE PERMISSIONS FOR \"$fil\"" >>$CKLOG ; bad=1 ; }
  72.     test -r $fil || { echo "NO READ  PERMISSIONS FOR \"$fil\"" >>$CKLOG ; bad=1 ; }
  73. test "$bad" = "1" && echo ERROR
  74. }
  75.  
  76. File_RChk() {
  77. fil=$1
  78. bad=0
  79. # Is it a null variable?
  80. test -n "$fil" || { echo "UNDEFINED VARIABLE" >>$CKLOG ; echo ERROR ; return ; }
  81. # Check file's permissions
  82.     test -r $fil || { echo "NO READ  PERMISSIONS FOR \"$fil\"" >>$CKLOG ; bad=1 ; }
  83. test "$bad" = "1" && echo ERROR
  84. }
  85.  
  86.  
  87. # --------- MAIN (main) ---------
  88. test "$RNADIR" || {
  89. #    Hey. Something is wrong with environment: i can't find the most
  90. #    important variable!! Be verbose, try to say something..
  91.     echo "*** PANIC: ENVIRONMENT MISSING! ***\n\
  92. I can't find RNALIB's environment; probably you are running this program\n\
  93. as a standalone module, while it should run as an argument of XRNA.."
  94. #    Let's do a core dump (!) inside tmp
  95.     echo "(core dumped in /tmp/core-rna.$$)"
  96.     set >/tmp/core-rna.$$
  97.     exit
  98. }
  99.  
  100. test $DEBUG && echo "***** RNALIB DIAGNOSTICS 1.00 *****"
  101. Init_Log
  102.  
  103. test $DEBUG && echo "Checking ownership of TMPDIR  ... \c"
  104. output="`Dir_Chk $TMPDIR`"
  105. test -n "$output" && {
  106.     test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  107.     Stop_Rna
  108.     exit
  109. }
  110. test $DEBUG && echo "PASSED"
  111.  
  112. test -n "$CONVDIR" && {
  113.     test $DEBUG && echo "Checking ownership of CONVDIR ... \c"
  114.     output="`Dir_Chk $CONVDIR`"
  115.     test -n "$output" && {
  116.         test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  117.         Stop_Rna
  118.         exit
  119.     }
  120.     test $DEBUG && echo "PASSED"
  121. }
  122. test -z "$CONVDIR" && {
  123.     test $DEBUG && echo "[ CONVDIR not used - skipped ]"
  124. }
  125.  
  126. test -n "$SPLITDIR" && {
  127.     test $DEBUG && echo "Checking ownership of SPLITDIR... \c"
  128.     output="`Dir_Chk $SPLITDIR`"
  129.     test -n "$output" && {
  130.         test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  131.         Stop_Rna
  132.         exit
  133.     }
  134.     test $DEBUG && echo "PASSED"
  135. }
  136. test -z "$CONVDIR" && {
  137.     test $DEBUG && echo "[ SPLITDIR not used - skipped ]"
  138. }
  139.  
  140. test -n "$PATHSIZE" && {
  141.     test $DEBUG && echo "Checking ownership of PATHSIZE... \c"
  142.     output="`File_RWChk $PATHSIZE`"
  143.     test -n "$output" && {
  144.         test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  145.         Stop_Rna
  146.         exit
  147.     }
  148.     test $DEBUG && echo "PASSED"
  149. }
  150. test -z "$PATHSIZE" && {
  151.     test $DEBUG && echo "[ PATHSIZE not used - skipped ]"
  152. }
  153.  
  154. test -n "$TIME_LIMITS" && {
  155.     test $DEBUG && echo "Checking ownership of TIME_LIMITS... \c"
  156.     output="`File_RChk $TIME_LIMITS`"
  157.     test -n "$output" && {
  158.         test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  159.         Stop_Rna
  160.         exit
  161.     }
  162.     test $DEBUG && echo "PASSED"
  163. }
  164. test -z "$TIME_LIMITS" && {
  165.     test $DEBUG && echo "[ TIME_LIMITS not used - skipped ]"
  166. }
  167.  
  168. test -f "$LOGFILE" && {
  169.     test $DEBUG && echo "Checking ownership of LOGFILE ... \c"
  170.     output="`File_RWChk $LOGFILE`"
  171.     test -n "$output" && {
  172.         test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  173.         Stop_Rna
  174.         exit
  175.     }
  176.     test $DEBUG && echo "PASSED"
  177. }
  178.  
  179. test -f "$MAIL_LOG" && {
  180.     test $DEBUG && echo "Checking ownership of MAIL_LOG... \c"
  181.     output="`File_RWChk $MAIL_LOG`"
  182.     test -n "$output" && {
  183.         test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  184.         Stop_Rna
  185.         exit
  186.     }
  187.     test $DEBUG && echo "PASSED"
  188. }
  189.  
  190.  
  191. test $DEBUG && echo "Checking ownership of LIBIND  ... \c"
  192. output="`File_RChk $LIBIND`"
  193. test -n "$output" && {
  194.     test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  195.     Stop_Rna
  196.     exit
  197. }
  198. test $DEBUG && echo "PASSED"
  199.  
  200. test -n "$LSTIND" && {
  201.     test $DEBUG && echo "Checking ownership of LSTIND  ... \c"
  202.     output="`File_RChk $LSTIND`"
  203.     test -n "$output" && {
  204.         test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  205.         Stop_Rna
  206.         exit
  207.     }
  208.     test $DEBUG && echo "PASSED"
  209. }
  210. test -z "$LSTIND" && {
  211.     test $DEBUG && echo "[ LSTIND not used - skipped ]"
  212. }
  213.  
  214.  
  215. test $DEBUG && echo "Checking ownership of BLACKLIST.. \c"
  216. output="`File_RChk $BLACKLIST`"
  217. test -n "$output" && {
  218.     test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  219.     Stop_Rna
  220.     exit
  221. }
  222. test $DEBUG && echo "PASSED"
  223.  
  224. test $DEBUG && echo "Checking ownership of WHITELIST.. \c"
  225. output="`File_RChk $WHITELIST`"
  226. test -n "$output" && {
  227.     test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  228.     Stop_Rna
  229.     exit
  230. }
  231. test $DEBUG && echo "PASSED"
  232.  
  233. test -f "$REJECTED" && {
  234.     test $DEBUG && echo "Checking ownership of REJECTED... \c"
  235.     output="`File_RWChk $REJECTED`"
  236.     test -n "$output" && {
  237.         test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  238.         Stop_Rna
  239.         exit
  240.     }
  241.     test $DEBUG && echo "PASSED"
  242. }
  243.  
  244. test -f "$RNADIR/hold" && {
  245.     test $DEBUG && echo "[ RNALIB IS ON HOLD ]\nChecking ownership of hold... \c"
  246.     output="`File_RChk $RNADIR/hold`"
  247.     test -n "$output" && {
  248.         test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  249.         Stop_Rna
  250.         exit
  251.     }
  252.     test $DEBUG && echo "PASSED"
  253. }
  254.  
  255. test -f "$RNADIR/pending" && {
  256.     test $DEBUG && echo "[ RNALIB HAS PENDING JOBS ]\nChecking ownership of pending... \c"
  257.     output="`File_RChk $RNADIR/pending`"
  258.     test -n "$output" && {
  259.         test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  260.         Stop_Rna
  261.         exit
  262.     }
  263.     test $DEBUG && echo "PASSED"
  264. }
  265.  
  266. test -f "$RNADIR/release" && {
  267.     test $DEBUG && echo "Checking ownership of release ... \c"
  268.     output="`File_RChk $RNADIR/release`"
  269.     test -n "$output" && {
  270.         test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
  271.         Stop_Rna
  272.         exit
  273.     }
  274.     test $DEBUG && echo "PASSED"
  275. } || {
  276.     test $DEBUG && echo "[ optional \"$RNADIR/release\" file missing ]"
  277.     }
  278.  
  279. # If you wish to see release, then uncomment the following line:
  280. #test $DEBUG && Release_Msg
  281. # (which is equivalent of:  XRNA Release_Msg)
  282.  
  283.  
  284. # If we get here, all is OK, and RNA can continue (at least for checkup)
  285. test $DEBUG && echo "****** DIAGNOSTICS COMPLETED ******"
  286. echo RRUN >$TMPDIR/status
  287.