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-2006
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script produces the plots from all root-files in the web directory
|
---|
28 | #
|
---|
29 | # After checking, if the script is already running, the plots are produced:
|
---|
30 | # With the programm showplot a ps-file is written, from which the png
|
---|
31 | # files are produced.
|
---|
32 | #
|
---|
33 |
|
---|
34 | user=`whoami`
|
---|
35 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
---|
36 |
|
---|
37 | set -C
|
---|
38 |
|
---|
39 | cd $mars
|
---|
40 |
|
---|
41 | datetime=`date +%F-%H-%M-%S`
|
---|
42 | webdir=/www/htdocs/datacenter
|
---|
43 |
|
---|
44 | scriptlogpath=$logpath/run/dowebplots/`date +%Y/%m/%d`
|
---|
45 | makedir $scriptlogpath
|
---|
46 |
|
---|
47 | scriptlog=$scriptlogpath/dowebplots-$datetime.log
|
---|
48 |
|
---|
49 | date >> $scriptlog 2>&1
|
---|
50 |
|
---|
51 | # check if script is already running
|
---|
52 | lockfile=$lockpath/lock-dowebplots.txt
|
---|
53 | date > $lockfile >> $scriptlog 2>&1
|
---|
54 | checklock0=$?
|
---|
55 | case $checklock0 in
|
---|
56 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
---|
57 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
---|
58 | echo "-> for datacheck is running -> exit" >> $scriptlog 2>&1
|
---|
59 | date >> $scriptlog 2>&1
|
---|
60 | exit;;
|
---|
61 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
62 | esac
|
---|
63 |
|
---|
64 |
|
---|
65 | #finding all rootfiles in the webdirectory
|
---|
66 | #this are all statusdisplays
|
---|
67 | rootfiles=`find $webdir/{sinope,callisto,star,ganymed}/ -name '*.root' -maxdepth 10 | grep -v '_I_' | grep -v '_Y_' | grep -v 'subsystemdata' | grep -v 'star_lapalma'`
|
---|
68 |
|
---|
69 | #exit if no rootfiles are found
|
---|
70 | if [ "$rootfiles" = "" ]
|
---|
71 | then
|
---|
72 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
73 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
74 | date >> $scriptlog 2>&1
|
---|
75 | exit
|
---|
76 | fi
|
---|
77 |
|
---|
78 | #produce plots for each rootfile
|
---|
79 | for rootfile in ${rootfiles[@]}
|
---|
80 | do
|
---|
81 | date >> $scriptlog 2>&1
|
---|
82 | #get names of the psfile and the
|
---|
83 | #pngfiles (1 per tab in the statusdiplay)
|
---|
84 | psfile=`echo $rootfile | sed -e 's/.root$/.ps/g'`
|
---|
85 | tabfile=`echo $rootfile | sed -e 's/.root$/-tab/g'`
|
---|
86 | echo "rootfile: $rootfile" >> $scriptlog 2>&1
|
---|
87 | echo "psfile: $psfile" >> $scriptlog 2>&1
|
---|
88 | echo "tabfile: $tabfile" >> $scriptlog 2>&1
|
---|
89 |
|
---|
90 | #get date of root- and psfile
|
---|
91 | daterootfile=`date +%Y%m%d -r $rootfile` >> $scriptlog 2>&1
|
---|
92 | datepsfile=`date +%Y%m%d -r $psfile` >> $scriptlog 2>&1
|
---|
93 | if [ "$datepsfile" = "" ]
|
---|
94 | then
|
---|
95 | echo "date of psfile is empty -> the file $psfile doesn't exist" >> $scriptlog 2>&1
|
---|
96 | echo " -> setting date to 0 and producing psfile..." >> $scriptlog 2>&1
|
---|
97 | datepsfile=0
|
---|
98 | fi
|
---|
99 |
|
---|
100 | echo "checking date..." >> $scriptlog 2>&1
|
---|
101 | echo "date of rootfile: $daterootfile" >> $scriptlog 2>&1
|
---|
102 | echo "date of psfile: $datepsfile" >> $scriptlog 2>&1
|
---|
103 |
|
---|
104 | #if the psfile is newer than the rootfile
|
---|
105 | #no plots have to be done -> continue
|
---|
106 | if [ "$datepsfile" -gt "$daterootfile" ] >> $scriptlog 2>&1
|
---|
107 | then
|
---|
108 | echo "psfile is older than rootfile -> continue " >> $scriptlog 2>&1
|
---|
109 | continue
|
---|
110 | fi
|
---|
111 |
|
---|
112 | echo "producing psfile..." >> $scriptlog 2>&1
|
---|
113 | ./showplot -b --save-as-ps=$psfile $rootfile >> $scriptlog 2>&1
|
---|
114 |
|
---|
115 | echo "converting plots to png..." >> $scriptlog 2>&1
|
---|
116 | pstoimg -antialias -flip r270 -density 100 -type png -multipage -out=$tabfile $psfile >> $scriptlog 2>&1
|
---|
117 | done
|
---|
118 |
|
---|
119 | echo "removing old files" >> $scriptlog 2>&1
|
---|
120 | #make sure, that old plots of files, that are already removed from disk,
|
---|
121 | # are deleted also in the webdirectory
|
---|
122 | #this has to be done, as ps and png files are excluded from rsync, and
|
---|
123 | #as rsync is done with --delete option (script /home/operator/condor/webupdate)
|
---|
124 |
|
---|
125 | #find all directories with plots
|
---|
126 | dirs=`find $webdir/{star,callisto,ganymed,sinope}/* -type d | grep -v merpplogs`
|
---|
127 |
|
---|
128 | for dir in ${dir[@]}
|
---|
129 | do
|
---|
130 | #find psfiles in directory
|
---|
131 | psfiles=`ls $dir/*.ps`
|
---|
132 | #continue, if there are no psfiles
|
---|
133 | if [ "$psfiles" == "" ]
|
---|
134 | then
|
---|
135 | continue
|
---|
136 | fi
|
---|
137 |
|
---|
138 | for psfile in ${psfiles[@]}
|
---|
139 | do
|
---|
140 | #create name of corresponding rootfile
|
---|
141 | rootfile=`echo $psfile | sed -e 's/.ps$/.root/g'`
|
---|
142 | #delete ps and pngfiles if rootfile is not existing
|
---|
143 | if ! ls $rootfile >> $scriptlog 2>&1
|
---|
144 | then
|
---|
145 | echo "deleting old plots for $rootfile..." >> $scriptlog 2>&1
|
---|
146 | path=`dirname $psfile`
|
---|
147 | rm -v $psfile >> $scriptlog 2>&1
|
---|
148 | rm -v $path/*.png >> $scriptlog 2>&1
|
---|
149 | fi
|
---|
150 | done
|
---|
151 | done
|
---|
152 |
|
---|
153 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
154 |
|
---|
155 | set +C
|
---|
156 |
|
---|
157 | date >> $scriptlog 2>&1
|
---|
158 |
|
---|