| 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 | scriptlog=$runlogpath/$program-$datetime.log | 
|---|
| 46 | date >> $scriptlog 2>&1 | 
|---|
| 47 |  | 
|---|
| 48 | # check whether script is already running | 
|---|
| 49 | lockfile=$lockpath/lock-$program.txt | 
|---|
| 50 | checklock  >> $scriptlog 2>&1 | 
|---|
| 51 |  | 
|---|
| 52 | # change permission for files | 
|---|
| 53 | ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/* >> $scriptlog 2>&1 | 
|---|
| 54 | ssh lapalma@dc09 chmod -R g+w /magic/datacenter/fromlapalma/RAW*/ >> $scriptlog 2>&1 | 
|---|
| 55 | # output for chmod with -v or -c (only changes) | 
|---|
| 56 |  | 
|---|
| 57 | printprocesslog "INFO moving directories from fromlapalma to fromtape" | 
|---|
| 58 | #find directories which have to be copied | 
|---|
| 59 | dirs=`ls /magic/datacenter/fromlapalma/RAW/*/*.OK | sed -e 's/.OK//g'` | 
|---|
| 60 | if [ ! "$dirs" == "" ] | 
|---|
| 61 | then | 
|---|
| 62 | # change permission for this directories | 
|---|
| 63 | ssh lapalma@dc09 chmod -R g+w $dirs >> $scriptlog 2>&1 | 
|---|
| 64 | # move directories to the tapedirectory | 
|---|
| 65 | dates=`find /magic/datacenter/fromlapalma/RAW/*200* -type d | cut -d/ -f6` | 
|---|
| 66 | for date in ${dates[@]} | 
|---|
| 67 | do | 
|---|
| 68 | ssh lapalma@dc09 mkdir /magic/datacenter/fromlapalma/RAWchk/$date >> $scriptlog 2>&1 | 
|---|
| 69 | makedir /magic/datacenter/fromtape/rawdata/$date >> $scriptlog 2>&1 | 
|---|
| 70 |  | 
|---|
| 71 | OKs=`ls /magic/datacenter/fromlapalma/RAW/$date/*.OK` | 
|---|
| 72 | for OK in ${OKs[@]} | 
|---|
| 73 | do | 
|---|
| 74 | ssh lapalma@dc09 mv -v $OK /magic/datacenter/fromlapalma/RAWchk/$date/ >> $scriptlog 2>&1 | 
|---|
| 75 | files=`echo $OK | sed -e 's/.OK//g'` | 
|---|
| 76 | mv -v $files /magic/datacenter/fromtape/rawdata/$date/ >> $scriptlog 2>&1 | 
|---|
| 77 | done | 
|---|
| 78 | done | 
|---|
| 79 | fi | 
|---|
| 80 |  | 
|---|
| 81 | rmdir -v /magic/datacenter/fromlapalma/RAW/*200* >> $scriptlog 2>&1 | 
|---|
| 82 |  | 
|---|
| 83 | # find rawfiles | 
|---|
| 84 | rawfiles=`find /magic/datacenter/fromtape/rawdata/ -name '*.*'` | 
|---|
| 85 |  | 
|---|
| 86 | if [ "$rawfiles" == "" ] | 
|---|
| 87 | then | 
|---|
| 88 | echo "no files to move -> exit" >> $scriptlog 2>&1 | 
|---|
| 89 | finish >> $scriptlog 2>&1 | 
|---|
| 90 | fi | 
|---|
| 91 |  | 
|---|
| 92 | printprocesslog "INFO moving rawfiles to $datapath/rawfiles" | 
|---|
| 93 | for rawfile in $rawfiles | 
|---|
| 94 | do | 
|---|
| 95 | # workaround for rawfiles with wrong timing | 
|---|
| 96 | #   newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles-wrong-timing/g' -e 's/_/\//1' -e 's/_/\//1'` | 
|---|
| 97 | newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles/g' -e 's/_/\//1' -e 's/_/\//1'` | 
|---|
| 98 | newdir=`dirname $newrawfile` | 
|---|
| 99 | makedir $newdir >> $scriptlog 2>&1 | 
|---|
| 100 |  | 
|---|
| 101 | mv -v $rawfile $newrawfile >> $scriptlog 2>&1 | 
|---|
| 102 | done | 
|---|
| 103 |  | 
|---|
| 104 | rmdir -v /magic/datacenter/fromtape/rawdata/* >> $scriptlog 2>&1 | 
|---|
| 105 |  | 
|---|
| 106 | printprocesslog "INFO launching filesondisk" | 
|---|
| 107 | echo "launching filesondisk" >> $scriptlog 2>&1 | 
|---|
| 108 | $scriptspath/filesondisk& | 
|---|
| 109 |  | 
|---|
| 110 | finish >> $scriptlog 2>&1 | 
|---|
| 111 |  | 
|---|