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/2004 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
21 | # Author(s): Stefan Ruegamer 02/2007 <mailto:snruegam@astro.uni-wuerzburg.de>
|
---|
22 | #
|
---|
23 | # Copyright: MAGIC Software Development, 2000-2007
|
---|
24 | #
|
---|
25 | #
|
---|
26 | # ========================================================================
|
---|
27 | #
|
---|
28 | # This script is moving the rawfiles from the directory
|
---|
29 | # /magic/datacenter/fromtape/rawdata to the structure
|
---|
30 | # /magic/data/rawfiles/YYYY/MM/DD
|
---|
31 | #
|
---|
32 | # Before running this script via cronjob, a check has to be included
|
---|
33 | # which logs in to La Palma and checks if the corresponding link in the
|
---|
34 | # Wuerbzurg transfer folder has already been deleted (else the file will
|
---|
35 | # be transferred again after moving)
|
---|
36 | #
|
---|
37 |
|
---|
38 | source `dirname $0`/sourcefile
|
---|
39 | printprocesslog "INFO starting $0"
|
---|
40 | program=movingrawfiles_OK
|
---|
41 |
|
---|
42 | set -C
|
---|
43 | umask 0002
|
---|
44 |
|
---|
45 | # check whether script is already running
|
---|
46 | lockfile=$lockpath/lock-$program.txt
|
---|
47 | checklock
|
---|
48 |
|
---|
49 | # change permission for files
|
---|
50 | ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/*
|
---|
51 | ssh lapalma@dc09 chmod -R g+w /magic/datacenter/fromlapalma/RAW*/
|
---|
52 | # output for chmod with -v or -c (only changes)
|
---|
53 |
|
---|
54 | printprocesslog "INFO moving directories from fromlapalma to fromtape"
|
---|
55 | #find directories which have to be copied
|
---|
56 | dirs=`ls /magic/datacenter/fromlapalma/RAW/*/*.OK | sed -e 's/.OK//g'`
|
---|
57 | if [ ! "$dirs" == "" ]
|
---|
58 | then
|
---|
59 | # change permission for this directories
|
---|
60 | ssh lapalma@dc09 chmod -R g+w $dirs
|
---|
61 | # move directories to the tapedirectory
|
---|
62 | dates=`find /magic/datacenter/fromlapalma/RAW/*200* -type d | cut -d/ -f6`
|
---|
63 | for date in ${dates[@]}
|
---|
64 | do
|
---|
65 | ssh lapalma@dc09 mkdir /magic/datacenter/fromlapalma/RAWchk/$date
|
---|
66 | makedir /magic/datacenter/fromtape/rawdata/$date
|
---|
67 |
|
---|
68 | OKs=`ls /magic/datacenter/fromlapalma/RAW/$date/*.OK`
|
---|
69 | for OK in ${OKs[@]}
|
---|
70 | do
|
---|
71 | ssh lapalma@dc09 mv -v $OK /magic/datacenter/fromlapalma/RAWchk/$date/
|
---|
72 | files=`echo $OK | sed -e 's/.OK//g'`
|
---|
73 | mv -v $files /magic/datacenter/fromtape/rawdata/$date/
|
---|
74 | done
|
---|
75 | done
|
---|
76 | fi
|
---|
77 |
|
---|
78 | rmdir -v /magic/datacenter/fromlapalma/RAW/*200*
|
---|
79 |
|
---|
80 | # find rawfiles
|
---|
81 | rawfiles=`find /magic/datacenter/fromtape/rawdata/ -name '*.*'`
|
---|
82 |
|
---|
83 | if [ "$rawfiles" == "" ]
|
---|
84 | then
|
---|
85 | printprocesslog "INFO no files to move -> exit"
|
---|
86 | finish
|
---|
87 | fi
|
---|
88 |
|
---|
89 | printprocesslog "INFO moving rawfiles to $datapath/rawfiles"
|
---|
90 | for rawfile in $rawfiles
|
---|
91 | do
|
---|
92 | # workaround for rawfiles with wrong timing
|
---|
93 | # newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles-wrong-timing/g' -e 's/_/\//1' -e 's/_/\//1'`
|
---|
94 | newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles/g' -e 's/_/\//1' -e 's/_/\//1'`
|
---|
95 | newdir=`dirname $newrawfile`
|
---|
96 | makedir $newdir
|
---|
97 |
|
---|
98 | mv -v $rawfile $newrawfile
|
---|
99 | done
|
---|
100 |
|
---|
101 | rmdir -v /magic/datacenter/fromtape/rawdata/*
|
---|
102 |
|
---|
103 | printprocesslog "INFO launching filesondisk"
|
---|
104 | $scriptspath/filesondisk&
|
---|
105 |
|
---|
106 | finish
|
---|
107 |
|
---|