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 |
|
---|
29 | user=`whoami`
|
---|
30 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
---|
31 |
|
---|
32 | set -C
|
---|
33 |
|
---|
34 | cd $mars
|
---|
35 |
|
---|
36 | datetime=`date +%F-%H-%M-%S`
|
---|
37 | webdir=/www/htdocs/datacenter
|
---|
38 |
|
---|
39 | scriptlogpath=$logpath/run/dowebplots/`date +%Y/%m/%d`
|
---|
40 | makedir $scriptlogpath
|
---|
41 |
|
---|
42 | scriptlog=$scriptlogpath/dowebplots-$datetime.log
|
---|
43 |
|
---|
44 | date >> $scriptlog 2>&1
|
---|
45 |
|
---|
46 | lockfile=$lockpath/lock-dowebplots.txt
|
---|
47 | date > $lockfile >> $scriptlog 2>&1
|
---|
48 | checklock0=$?
|
---|
49 | case $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;;
|
---|
56 | esac
|
---|
57 |
|
---|
58 |
|
---|
59 | #finding all rootfiles in the webdirectory
|
---|
60 | #this are all statusdisplays
|
---|
61 | rootfiles=`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
|
---|
64 | if [ "$rootfiles" = "" ]
|
---|
65 | then
|
---|
66 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
67 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
68 | date >> $scriptlog 2>&1
|
---|
69 | exit
|
---|
70 | fi
|
---|
71 |
|
---|
72 |
|
---|
73 | #produce plots for each rootfile
|
---|
74 | for rootfile in ${rootfiles[@]}
|
---|
75 | do
|
---|
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
|
---|
112 | done
|
---|
113 |
|
---|
114 | echo "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
|
---|
121 | dirs=`find $webdir/{star,callisto,ganymed,sinope}/* -type d | grep -v merpplogs`
|
---|
122 |
|
---|
123 | for dir in ${dir[@]}
|
---|
124 | do
|
---|
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
|
---|
146 | done
|
---|
147 |
|
---|
148 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
149 |
|
---|
150 | set +C
|
---|
151 |
|
---|
152 | date >> $scriptlog 2>&1
|
---|
153 |
|
---|