Project

General

Profile

metacat / src / scripts / bash / check_shape_file_existence.sh @ 4810

1
#!/bin/bash
2
#This file will check if shape files exist or not.
3
#If one is deleted and a email will be sent to tao with the tomcat log.
4
#Note: if file eml_message already exists in current dir, email wouldn't send again.
5
#This setting will make sure only one email will sent. Otherwise, my email account will be over quota.
6
target_file1=/var/www/org.ecoinformatics.knb/knb/data/metacat_shps/data_points.dbf
7
target_file2=/var/www/org.ecoinformatics.knb/knb/data/metacat_shps/data_points.shp
8
target_file3=/var/www/org.ecoinformatics.knb/knb/data/metacat_shps/data_points.shx
9
target_file4=/var/www/org.ecoinformatics.knb/knb/data/metacat_shps/data_bounds.dbf
10
target_file5=/var/www/org.ecoinformatics.knb/knb/data/metacat_shps/data_bounds.shp
11
target_file6=/var/www/org.ecoinformatics.knb/knb/data/metacat_shps/data_bounds.shx
12

    
13
log_file=/var/log/tomcat/catalina.out
14
sender_email_address=knb_tomcat@ecoinformatics.org
15
receiver_email_address=tao@nceas.ucsb.edu
16
tmp=/root/email_message
17
if [ ! -e $target_file1 -o ! -e $target_file2 -o ! -e $target_file3 -o ! -e $target_file4 -o ! -e $target_file5 -o ! -e $target_file6 ]
18
 then
19
   if [ ! -e $tmp ]
20
     then
21
       touch $tmp && chmod 600 $tmp
22
       echo -e "subject: Shape file was deleted at `date`\n" > $tmp
23
       echo -e "\n log file info: " >> $tmp
24
       echo -e "\n `tail -300 $log_file`" >> $tmp
25
       /usr/sbin/sendmail -f $sender_email_address $receiver_email_address < $tmp
26
   fi
27
fi