| 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 | # | 
|---|
| 22 | #   Copyright: MAGIC Software Development, 2000-2006 | 
|---|
| 23 | # | 
|---|
| 24 | # | 
|---|
| 25 | # ======================================================================== | 
|---|
| 26 | # | 
|---|
| 27 | # This script is moving the rawfiles from the directory | 
|---|
| 28 | # /magic/datacenter/fromtape/rawdata to the structure | 
|---|
| 29 | # /magic/data/rawfiles/YYYY/MM/DD | 
|---|
| 30 | # | 
|---|
| 31 |  | 
|---|
| 32 | source `dirname $0`/sourcefile | 
|---|
| 33 | printprocesslog "INFO starting $0" | 
|---|
| 34 | program=movingrawfiles | 
|---|
| 35 |  | 
|---|
| 36 | set -C | 
|---|
| 37 | umask 0002 | 
|---|
| 38 |  | 
|---|
| 39 | scriptlog=$runlogpath/$program-$datetime.log | 
|---|
| 40 | date >> $scriptlog 2>&1 | 
|---|
| 41 |  | 
|---|
| 42 | # check if script is already running | 
|---|
| 43 | lockfile=$lockpath/lock-$program.txt | 
|---|
| 44 | checklock  >> $scriptlog 2>&1 | 
|---|
| 45 |  | 
|---|
| 46 | # change permission for files | 
|---|
| 47 | ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/* >> $scriptlog 2>&1 | 
|---|
| 48 | # output for chmod with -v or -c (only changes) | 
|---|
| 49 |  | 
|---|
| 50 | printprocesslog "INFO moving directories from fromlapalma to fromtape" | 
|---|
| 51 | #find directories, which have to be copied | 
|---|
| 52 | dirs=`ls /magic/datacenter/fromlapalma/RAWchk/*/*.finished | sed -e 's/RAWchk/RAW/g' | cut -d/ -f1-6` | 
|---|
| 53 | if [ ! "$dirs" == "" ] | 
|---|
| 54 | then | 
|---|
| 55 | # change permission for this dirctories | 
|---|
| 56 | ssh lapalma@apollo chmod -R g+w $dirs >> $scriptlog 2>&1 | 
|---|
| 57 | # move directories to the tapedirectory | 
|---|
| 58 | mv -v $dirs /magic/datacenter/fromtape/rawdata/ >> $scriptlog 2>&1 | 
|---|
| 59 | fi | 
|---|
| 60 |  | 
|---|
| 61 |  | 
|---|
| 62 | # find rawfiles | 
|---|
| 63 | rawfiles=`find /magic/datacenter/fromtape/rawdata/ -name '*.*'` | 
|---|
| 64 |  | 
|---|
| 65 | if [ "$rawfiles" == "" ] | 
|---|
| 66 | then | 
|---|
| 67 | echo "no files to move -> exit" >> $scriptlog 2>&1 | 
|---|
| 68 | finish >> $scriptlog 2>&1 | 
|---|
| 69 | fi | 
|---|
| 70 |  | 
|---|
| 71 | printprocesslog "INFO moving moving rawfiles to $datapath/rawfiles" | 
|---|
| 72 | for rawfile in $rawfiles | 
|---|
| 73 | do | 
|---|
| 74 | # workaround for rawfiles with wrong timing | 
|---|
| 75 | #  newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles-wrong-timing/g' -e 's/_/\//1' -e 's/_/\//1'` | 
|---|
| 76 | newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles/g' -e 's/_/\//1' -e 's/_/\//1'` | 
|---|
| 77 | newdir=`dirname $newrawfile` | 
|---|
| 78 | makedir $newdir >> $scriptlog 2>&1 | 
|---|
| 79 |  | 
|---|
| 80 | mv -v $rawfile $newrawfile >> $scriptlog 2>&1 | 
|---|
| 81 | done | 
|---|
| 82 |  | 
|---|
| 83 | rmdir -v /magic/datacenter/fromtape/rawdata/* >> $scriptlog 2>&1 | 
|---|
| 84 |  | 
|---|
| 85 | printprocesslog "INFO launching filesondisk" | 
|---|
| 86 | echo "launching filesondisk" >> $scriptlog 2>&1 | 
|---|
| 87 | $scriptspath/filesondisk& | 
|---|
| 88 |  | 
|---|
| 89 | finish >> $scriptlog 2>&1 | 
|---|
| 90 |  | 
|---|