home *** CD-ROM | disk | FTP | other *** search
- :
- # RNALIB Support Utilities
- # checkup 1.0
- #
- # Performs a bunch of checks upon the whole RNALIB's
- # environment. It will not allow RNALIB to continue processing any
- # mail unless specified.
- # To let RNA continue its work, a $TMPDIR/status file should be
- # created containing "RRUN".
- #
- # Common variables.
- CKLOG="/tmp/chkuplog.$$"
- rm -f /tmp/chkuplog.* 2>/dev/null
-
- # Common routines.
-
- # Check directory and files.
- # Returns: nothing if everything is ok.
-
- # Initlog
- Init_Log() {
- >$CKLOG || echo "WARNING: cannot open logfile $CKLOG"
- }
-
- Stop_Msg() {
- echo "\
- WARNING\n\
- An unrecoverable error was detected inside RNALIB's environment/file system.\n\
- RNALIB HAS NOW BEEN STOP BY CREATING \"$RNADIR/stop\";\n\
- you need to remove this file by hand in order to let RNALIB run again."
-
- }
-
- Sig_Msg() {
- echo "\n\n\
- Sincerely,\n\
- your RNALIB daemon \"checkup\""
- }
-
-
- Stop_Rna() {
- date >$RNADIR/stop
- echo "Subject: RNALIB CHECKUP PROBLEMS - STOP\n\n\
- `Stop_Msg`\n\nDiagnostic follows:\n`cat $CKLOG`\n`Sig_Msg`" | $MAILER $POSTMASTER
- }
-
-
- Dir_Chk() {
- dir=$1
- bad=0
- # Is it a null variable?
- test -n "$dir" || { echo "UNDEFINED VARIABLE" >>$CKLOG ; echo ERROR ; return ; }
- # Does 'dir' exist?
- test -d $dir || { echo "NONEXISTENT DIRECTORY \"$dir\"" >>$CKLOG ; echo ERROR ; return ; }
- # All files need to be readable and writable.
- for file in `ls $dir`
- do
- test -w $dir/$file || { echo "NO WRITE PERMISSIONS FOR \"$dir/$file\"" >>$CKLOG ; bad=1 ; }
- test -r $dir/$file || { echo "NO READ PERMISSIONS FOR \"$dir/$file\"" >>$CKLOG ; bad=1 ; }
- done
- test "$bad" = "1" && echo ERROR
-
- }
-
- File_RWChk() {
- fil=$1
- bad=0
- # Is it a null variable?
- test -n "$fil" || { echo "UNDEFINED VARIABLE" >>$CKLOG ; echo ERROR ; return ; }
- # Check file's permissions
- test -w $fil || { echo "NO WRITE PERMISSIONS FOR \"$fil\"" >>$CKLOG ; bad=1 ; }
- test -r $fil || { echo "NO READ PERMISSIONS FOR \"$fil\"" >>$CKLOG ; bad=1 ; }
- test "$bad" = "1" && echo ERROR
- }
-
- File_RChk() {
- fil=$1
- bad=0
- # Is it a null variable?
- test -n "$fil" || { echo "UNDEFINED VARIABLE" >>$CKLOG ; echo ERROR ; return ; }
- # Check file's permissions
- test -r $fil || { echo "NO READ PERMISSIONS FOR \"$fil\"" >>$CKLOG ; bad=1 ; }
- test "$bad" = "1" && echo ERROR
- }
-
-
- # --------- MAIN (main) ---------
- test "$RNADIR" || {
- # Hey. Something is wrong with environment: i can't find the most
- # important variable!! Be verbose, try to say something..
- echo "*** PANIC: ENVIRONMENT MISSING! ***\n\
- I can't find RNALIB's environment; probably you are running this program\n\
- as a standalone module, while it should run as an argument of XRNA.."
- # Let's do a core dump (!) inside tmp
- echo "(core dumped in /tmp/core-rna.$$)"
- set >/tmp/core-rna.$$
- exit
- }
-
- test $DEBUG && echo "***** RNALIB DIAGNOSTICS 1.00 *****"
- Init_Log
-
- test $DEBUG && echo "Checking ownership of TMPDIR ... \c"
- output="`Dir_Chk $TMPDIR`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
-
- test -n "$CONVDIR" && {
- test $DEBUG && echo "Checking ownership of CONVDIR ... \c"
- output="`Dir_Chk $CONVDIR`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
- }
- test -z "$CONVDIR" && {
- test $DEBUG && echo "[ CONVDIR not used - skipped ]"
- }
-
- test -n "$SPLITDIR" && {
- test $DEBUG && echo "Checking ownership of SPLITDIR... \c"
- output="`Dir_Chk $SPLITDIR`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
- }
- test -z "$CONVDIR" && {
- test $DEBUG && echo "[ SPLITDIR not used - skipped ]"
- }
-
- test -n "$PATHSIZE" && {
- test $DEBUG && echo "Checking ownership of PATHSIZE... \c"
- output="`File_RWChk $PATHSIZE`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
- }
- test -z "$PATHSIZE" && {
- test $DEBUG && echo "[ PATHSIZE not used - skipped ]"
- }
-
- test -n "$TIME_LIMITS" && {
- test $DEBUG && echo "Checking ownership of TIME_LIMITS... \c"
- output="`File_RChk $TIME_LIMITS`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
- }
- test -z "$TIME_LIMITS" && {
- test $DEBUG && echo "[ TIME_LIMITS not used - skipped ]"
- }
-
- test -f "$LOGFILE" && {
- test $DEBUG && echo "Checking ownership of LOGFILE ... \c"
- output="`File_RWChk $LOGFILE`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
- }
-
- test -f "$MAIL_LOG" && {
- test $DEBUG && echo "Checking ownership of MAIL_LOG... \c"
- output="`File_RWChk $MAIL_LOG`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
- }
-
-
- test $DEBUG && echo "Checking ownership of LIBIND ... \c"
- output="`File_RChk $LIBIND`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
-
- test -n "$LSTIND" && {
- test $DEBUG && echo "Checking ownership of LSTIND ... \c"
- output="`File_RChk $LSTIND`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
- }
- test -z "$LSTIND" && {
- test $DEBUG && echo "[ LSTIND not used - skipped ]"
- }
-
-
- test $DEBUG && echo "Checking ownership of BLACKLIST.. \c"
- output="`File_RChk $BLACKLIST`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
-
- test $DEBUG && echo "Checking ownership of WHITELIST.. \c"
- output="`File_RChk $WHITELIST`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
-
- test -f "$REJECTED" && {
- test $DEBUG && echo "Checking ownership of REJECTED... \c"
- output="`File_RWChk $REJECTED`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
- }
-
- test -f "$RNADIR/hold" && {
- test $DEBUG && echo "[ RNALIB IS ON HOLD ]\nChecking ownership of hold... \c"
- output="`File_RChk $RNADIR/hold`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
- }
-
- test -f "$RNADIR/pending" && {
- test $DEBUG && echo "[ RNALIB HAS PENDING JOBS ]\nChecking ownership of pending... \c"
- output="`File_RChk $RNADIR/pending`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
- }
-
- test -f "$RNADIR/release" && {
- test $DEBUG && echo "Checking ownership of release ... \c"
- output="`File_RChk $RNADIR/release`"
- test -n "$output" && {
- test $DEBUG && echo "FAILED. Reason:\n`cat $CKLOG`\n`Stop_Msg`"
- Stop_Rna
- exit
- }
- test $DEBUG && echo "PASSED"
- } || {
- test $DEBUG && echo "[ optional \"$RNADIR/release\" file missing ]"
- }
-
- # If you wish to see release, then uncomment the following line:
- #test $DEBUG && Release_Msg
- # (which is equivalent of: XRNA Release_Msg)
-
-
- # If we get here, all is OK, and RNA can continue (at least for checkup)
- test $DEBUG && echo "****** DIAGNOSTICS COMPLETED ******"
- echo RRUN >$TMPDIR/status
-