Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pre_processor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IA2
pre_processor
Commits
9d9a0fcb
Commit
9d9a0fcb
authored
8 months ago
by
Martina Vicinanza
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
a9101055
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
script/asiago_checkfits.sh
+209
-0
209 additions, 0 deletions
script/asiago_checkfits.sh
with
209 additions
and
0 deletions
script/asiago_checkfits.sh
0 → 100644
+
209
−
0
View file @
9d9a0fcb
#!/bin/bash
#: Title : checkfits.sh
#: Date : 2014/10/28
#: Author : "Marco De Marco" <demarco@oats.inaf.it>
#: Version : 1.0
#: Description : Fits verification and proccessing script
#Tools paths
VERIFY_TOOL
=
"/usr/local/bin/fitsverify"
LISTHEAD_TOOL
=
"/usr/local/bin/listhead"
MODHEAD_TOOL
=
"/usr/local/bin/modhead"
if
[
"
$1
"
==
"CHECK"
]
;
then
#: Section : CHECK
#: Parameter : none
#: Response : CHECK OK
#: : CHECK FATAL
#: Description : Check availability of script tools
#Check fitsverify tools
CHECK_STRING
=
"conform to the FITS format"
res
=
$(
$VERIFY_TOOL
2>&1
)
check
=
$(
echo
$res
|
grep
"
$CHECK_STRING
"
|
wc
|
awk
'{print $1}'
)
if
[
"
$check
"
-lt
"1"
]
;
then
echo
"CHECK FATAL"
exit
0
fi
#Check listhead tools
CHECK_STRING
=
"Usage: listhead filename"
res
=
$(
$LISTHEAD_TOOL
2>&1
)
check
=
$(
echo
$res
|
grep
"
$CHECK_STRING
"
|
wc
|
awk
'{print $1}'
)
if
[
"
$check
"
-lt
"1"
]
;
then
echo
"CHECK FATAL"
exit
0
fi
#Check modhead tools
CHECK_STRING
=
"Usage: modhead filename"
res
=
$(
$MODHEAD_TOOL
2>&1
)
check
=
$(
echo
$res
|
grep
"
$CHECK_STRING
"
|
wc
|
awk
'{print $1}'
)
if
[
"
$check
"
-lt
"1"
]
;
then
echo
"CHECK FATAL"
exit
0
fi
echo
"CHECK OK"
exit
0
elif
[
"
$1
"
==
"VALID"
]
;
then
#: Section : VALID
#: Parameter : file path
#: Response : VALID OK
#: : VALID IGNORE
#: Description : Check file name compliance
file
=
$2
file_name
=
${
file
##*/
}
#Check regex for rsync temporary file -> ignore
if
[[
!
"
${
file_name
,,
}
"
=
~ ^[^
\.
]
.
*
\.
(
fits|fit|fts
)
.
*
$
]]
;
then
echo
"VALID IGNORE: invalid regular expression"
exit
0
fi
echo
"VALID OK"
exit
0
elif
[
"
$1
"
==
"VERIFY"
]
;
then
#: Section : VERIFY
#: Parameter : file path
#: Response : VERIFY OK
#: : VERIFY WAIT
#: : VERIFY FATAL
#: Description : Check file compliance to fits format
file
=
$2
FATAL_ERROR
=
"Fatal"
EOF_ERROR
=
"End-of-file"
#Change file and permission before processing
/usr/bin/sudo
-n
/bin/chmod go+r
$file
#if fits verify tools exists -> fatal
if
[
!
-x
$VERIFY_TOOL
]
;
then
echo
"VERIFY FATAL : verify tools not exists"
exit
0
fi
#if fits file not exists -> fatal
if
[
!
-f
$file
]
;
then
echo
"VERIFY FATAL : file not exists"
exit
0
fi
#Check with fits verify
res
=
$(
$VERIFY_TOOL
$file
2>&1
)
#if fitsverify return fatal error -> wait
fatal
=
$(
echo
$res
|
grep
"
$FATAL_ERROR
"
|
wc
|
awk
'{print $1}'
)
if
[
"
$fatal
"
-ge
"1"
]
;
then
echo
"VERIFY FATAL"
exit
0
fi
#if fitsverify return end of file -> wait
eof
=
$(
echo
$res
|
grep
"
$EOF_ERROR
"
|
wc
|
awk
'{print $1}'
)
if
[
"
$eof
"
-ge
"1"
]
;
then
echo
"VERIFY WAIT"
exit
0
fi
#else -> ok
echo
"VERIFY OK"
exit
0
elif
[
"
$1
"
==
"PREPROCESS"
]
;
then
#: Section : PREPROCESS
#: Parameter : file path
#: : ingestion result [OK, WAIT, FATAL]
#: Response : PREPROCESS OK
#: : PREPROCESS FATAL
#: Description : Apply preprocessing before ingestion
file
=
$2
file_name
=
${
file
##*/
}
verified
=
$3
#Check verified parameter value
if
[
"
$verified
"
!=
"OK"
-a
"
$verified
"
!=
"WAIT"
-a
"
$verified
"
!=
"FATAL"
]
;
then
echo
"PREPROCESS FATAL"
exit
0
fi
#Pre processing for verified OK files
if
[
"
$verified
"
==
"OK"
]
;
then
#Change file ownership
/usr/bin/sudo
-n
/bin/chown controls:controls
$file
#Change file and permission before processing
/usr/bin/sudo
-n
/bin/chmod u+rw
$file
#Unpack Schmidt files
if
[[
"
${
file_name
##*.
}
"
==
fz
]]
;
then
funpack
-D
$file
fi
#Schmidt files
fi
#verified ok files
echo
"PREPROCESS OK"
exit
0
elif
[
"
$1
"
==
"POSTPROCESS"
]
;
then
#: Section : POSTPROCESS
#: Parameter : file path
#: : ingestion result [OK, WAIT, FATAL]
#: Response : POSTPROCESS OK
#: : POSTPROCESS FATAL
#: Description : Apply postprocessing after ingestion
file
=
$2
file_name
=
${
file
##*/
}
verified
=
$3
#Check verified parameter value
if
[
"
$verified
"
!=
"OK"
-a
"
$verified
"
!=
"WAIT"
-a
"
$verified
"
!=
"FATAL"
]
;
then
echo
"POSTPROCESS FATAL"
exit
0
fi
#Post process verified WAIT files
if
[
"
$verified
"
==
"WAIT"
]
;
then
echo
"Warning file:
$file_name
"
| mutt
-s
"Pre process log"
--
demarco@oats.inaf.it
fi
#Post process verified FATAL files
if
[
"
$verified
"
==
"FATAL"
]
;
then
echo
"Fatal file:
$file_name
"
| mutt
-s
"Pre process log"
--
demarco@oats.inaf.it
fi
echo
"POSTPROCESS OK"
exit
0
else
#: Section : DEFAULT
#: Parameter : none
#: Response : UNKNOWN
echo
"UNKNOWN"
exit
0
fi
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment