source: trunk/MagicSoft/Mars/datacenter/scripts/dowebplots@ 7454

Last change on this file since 7454 was 7454, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.7 KB
Line 
1#!/bin/sh
2#
3# ========================================================================
4#
5# *
6# * This file is part of MARS, the MAGIC Analysis and Reconstruction
7# * Software. It is distributed to you in the hope that it can be a useful
8# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
9# * It is distributed WITHOUT ANY WARRANTY.
10# *
11# * Permission to use, copy, modify and distribute this software and its
12# * documentation for any purpose is hereby granted without fee,
13# * provided that the above copyright notice appear in all copies and
14# * that both that copyright notice and this permission notice appear
15# * in supporting documentation. It is provided "as is" without express
16# * or implied warranty.
17# *
18#
19#
20# Author(s): Daniela Dorner 08/2005 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2004
23#
24#
25# ========================================================================
26#
27#
28
29user=`whoami`
30source /home/$user/Mars/datacenter/scripts/sourcefile
31
32set -C
33
34cd $mars
35
36datetime=`date +%F-%H-%M-%S`
37webdir=/www/htdocs/datacenter
38
39scriptlogpath=$logpath/run/dowebplots/`date +%Y/%m/%d`
40makedir $scriptlogpath
41
42scriptlog=$scriptlogpath/dowebplots-$datetime.log
43
44date >> $scriptlog 2>&1
45
46lockfile=$lockpath/lock-dowebplots.txt
47date > $lockfile >> $scriptlog 2>&1
48checklock0=$?
49case $checklock0 in
50 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
51 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
52 echo "-> for datacheck is running -> exit" >> $scriptlog 2>&1
53 date >> $scriptlog 2>&1
54 exit;;
55 *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
56esac
57
58
59#finding all rootfiles in the webdirectory
60#this are all statusdisplays
61rootfiles=`find $webdir/{sinope,callisto,star,ganymed}/ -name '*.root' -maxdepth 10 | grep -v '_I_' | grep -v '_Y_' | grep -v 'subsystemdata' | grep -v 'star_lapalma'`
62
63#exit if no rootfiles are found
64if [ "$rootfiles" = "" ]
65then
66 echo "nothing to do -> exit" >> $scriptlog 2>&1
67 rm -v $lockfile >> $scriptlog 2>&1
68 date >> $scriptlog 2>&1
69 exit
70fi
71
72
73#produce plots for each rootfile
74for rootfile in ${rootfiles[@]}
75do
76 date >> $scriptlog 2>&1
77 #get names of the psfile and the
78 #pngfiles (1 per tab in the statusdiplay)
79 psfile=`echo $rootfile | sed -e 's/.root$/.ps/g'`
80 tabfile=`echo $rootfile | sed -e 's/.root$/-tab/g'`
81 echo "rootfile: $rootfile" >> $scriptlog 2>&1
82 echo "psfile: $psfile" >> $scriptlog 2>&1
83 echo "tabfile: $tabfile" >> $scriptlog 2>&1
84
85 #get date of root- and psfile
86 daterootfile=`date +%Y%m%d -r $rootfile` >> $scriptlog 2>&1
87 datepsfile=`date +%Y%m%d -r $psfile` >> $scriptlog 2>&1
88 if [ "$datepsfile" = "" ]
89 then
90 echo "date of psfile is empty -> the file $psfile doesn't exist" >> $scriptlog 2>&1
91 echo " -> setting date to 0 and producing psfile..." >> $scriptlog 2>&1
92 datepsfile=0
93 fi
94
95 echo "checking date..." >> $scriptlog 2>&1
96 echo "date of rootfile: $daterootfile" >> $scriptlog 2>&1
97 echo "date of psfile: $datepsfile" >> $scriptlog 2>&1
98
99 #if the psfile is newer than the rootfile
100 #no plots have to be done -> continue
101 if [ "$datepsfile" -gt "$daterootfile" ] >> $scriptlog 2>&1
102 then
103 echo "psfile is older than rootfile -> continue " >> $scriptlog 2>&1
104 continue
105 fi
106
107 echo "producing psfile..." >> $scriptlog 2>&1
108 ./showplot -b --save-as-ps=$psfile $rootfile >> $scriptlog 2>&1
109
110 echo "converting plots to png..." >> $scriptlog 2>&1
111 pstoimg -antialias -flip r270 -density 100 -type png -multipage -out=$tabfile $psfile >> $scriptlog 2>&1
112done
113
114echo "removing old files" >> $scriptlog 2>&1
115#make sure, that old plots of files, that are already removed from disk,
116# are deleted also in the webdirectory
117#this has to be done, as ps and png files are excluded from rsync,
118#as rsync is done with --delete option (script /home/operator/condor/webupdate
119
120#find all directories with plots
121dirs=`find $webdir/{star,callisto,ganymed,sinope}/* -type d | grep -v merpplogs`
122
123for dir in ${dir[@]}
124do
125 #find psfiles in directory
126 psfiles=`ls $dir/*.ps`
127 #continue, if there are no psfiles
128 if [ "$psfiles" == "" ]
129 then
130 continue
131 fi
132
133 for psfile in ${psfiles[@]}
134 do
135 #create name of corresponding rootfile
136 rootfile=`echo $psfile | sed -e 's/.ps$/.root/g'`
137 #delete ps and pngfiles if rootfile is not existing
138 if ! ls $rootfile >> $scriptlog 2>&1
139 then
140 echo "deleting old plots for $rootfile..." >> $scriptlog 2>&1
141 path=`dirname $psfile`
142 rm -v $psfile >> $scriptlog 2>&1
143 rm -v $path/*.png >> $scriptlog 2>&1
144 fi
145 done
146done
147
148rm -v $lockfile >> $scriptlog 2>&1
149
150set +C
151
152date >> $scriptlog 2>&1
153
Note: See TracBrowser for help on using the repository browser.