source: trunk/DataCheck/Archive/auxIngest.sh@ 19569

Last change on this file since 19569 was 12871, checked in by lyard, 13 years ago
added more scripts
  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/bin/bash
2
3sourceFolder=$1
4destFolder=$2
5suffix=$3
6
7if [ "$#" != "3" ]
8then
9 echo "Please specify source and dest folders and suffix. Aborting"
10 exit
11fi
12
13if [ $1 == "" ]
14then
15 echo "Source folder is empty. Aborting"
16 exit
17fi
18
19if [ $2 == "" ]
20then
21 echo "Dest folder is empty. Aborting"
22 exit
23fi
24
25#first let's make sure that source and dest folders do exist, and that dest is writable
26if [ -d $1 ]
27then
28 sourceFolder=$1
29else
30 echo "Source folder "$1" does not exist (or cannnot be read.) Aborting"
31 exit
32fi
33
34if [ -d $2 ]
35then
36 if [ -d $2"/etiennetest" ]
37 then
38 echo "Test folder already exist. Aborting"
39 exit
40 fi
41 mkdir $2"/etiennetest" 2>/dev/null
42 if [ -d $2"/etiennetest" ]
43 then
44 rm -rf $2"/etiennetest"
45 destFolder=$2
46 else
47 echo "Dest folder is not writable. Aborting"
48 exit
49 fi
50else
51 echo "Dest folder does not exist. Aborting"
52 exit
53fi
54
55#files=`ls $destFolder`
56#if [ "$files" != "" ]
57#then
58# echo "Dest folder is not empty. Aborting"
59# exit
60#fi
61sourceFolder=${sourceFolder%/}
62destFolder=${destFolder%/}
63echo "Will start ingesting files from "$sourceFolder" to "$destFolder
64
65#list all the files in sourceFolder, and copy then with the same structure to destfolder
66
67entries=`find $sourceFolder -type f -name '*.fits' | sort`
68
69for entry in ${entries[@]}
70do
71 #first construct the correct file name
72 targetFileName=`correctFileName $entry`
73 #second construct the destination path.
74 filenameonly=${entry##*/}
75 pathonly=${entry%$filenameonly}
76 extrapathonly=${pathonly#$sourceFolder/}
77 targetFolder=$destFolder"/"$extrapathonly
78 if [ ! -d $targetFolder ]
79 then
80 mkdir -p $targetFolder
81 fi
82
83 #check if the file already exist there
84 targetFile=$targetFolder"/"$targetFileName
85 echo "$targetFile"
86 if [ -a $targetFile ]
87 then
88 echo "File $targetFile already exist. Skipping it" >> report_$suffix.txt
89 continue
90 fi
91 cp $entry $targetFile
92 #if not, do the copying, fixing and checking
93
94# grouping=`/home/isdc/lyard/FACT++/fitsdump $targetFile -h 2>/dev/null | grep GROUPING`
95
96# grouping=`grep 'GROUPING' "temp.txt"`
97
98# if [ "$grouping" == "" ]
99# then
100
101 repairAuxFile.sh $targetFile ENDerrors_$suffix.txt MJDerror_$suffix.txt report_$suffix.txt processErrors_$suffix.txt
102
103 if [ -a $targetFile ]
104 then
105 fixAuxKeyWords.sh $targetFile reportTwo_$suffix.txt processErrors_$suffix.txt
106 result=`fverify $targetFile 2>/dev/null | grep '0 error(s)'`
107 if [ "$result" == "" ]
108 then
109 echo "$targetFile" >> stillHasProblems_$suffix.txt
110 rm $targetFile
111 fi
112 fi
113done
114
115#set the correct permissions
116find $destFolder -type f -exec chmod 640 {} \;
117find $destFolder -type d -exec chmod 750 {} \;
118find $destFolder -exec chgrp fact {} \;
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
Note: See TracBrowser for help on using the repository browser.