Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
validate_workflows
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Digital Preservation
validate_workflows
Commits
7ed9c2d5
Commit
7ed9c2d5
authored
2 years ago
by
Andreas Romeyke
Browse files
Options
Downloads
Patches
Plain Diff
- fixes
#3
- changed help doc for --mode param
parent
e9978307
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
validate_workflow.sh
+51
-31
51 additions, 31 deletions
validate_workflow.sh
with
51 additions
and
31 deletions
validate_workflow.sh
+
51
−
31
View file @
7ed9c2d5
...
...
@@ -44,7 +44,7 @@
#hh -s, --statistics
#hh print a statistic
#hh -m, --mode [auto, mediathek, fotothek, save, kitodo, lfulg]
#hh the mode 'auto' tries to check files based on file
extension
s.
#hh the mode 'auto' tries to check files based on file
mime-type
s.
#hh The other modes are actual workflow names.
#hh -d, --daemon
#hh starts a daemon, works only in --files-mode=delete
...
...
@@ -109,9 +109,14 @@ calc_statistics() {
}
print_statistics
()
{
local stat
local
cnt_total
local
cnt_valid
local
cnt_invalid
local
ratio
stat
=
$(
calc_statistics
)
cnt_total
=
$(
echo
$stat
|
awk
'END {print $1}'
)
cnt_valid
=
$(
echo
$stat
|
awk
'END {print $2}'
)
cnt_total
=
$(
echo
"
$stat
"
|
awk
'END {print $1}'
)
cnt_valid
=
$(
echo
"
$stat
"
|
awk
'END {print $2}'
)
cnt_invalid
=
$((
cnt_total
-
cnt_valid
))
ratio
=
$((
100
*
cnt_valid
/
cnt_total
))
echo
"Validation Statistics"
...
...
@@ -122,11 +127,12 @@ print_statistics() {
}
update_statistics
()
{
is_valid
=
$1
duration
=
$2
ftype
=
$3
workflow
=
$4
stage
=
$5
local
is_valid
=
$1
local
duration
=
$2
local
ftype
=
$3
local
workflow
=
$4
local
stage
=
$5
local date
date
=
$(
date
+
"%F%T"
)
debug
"date=
$date
"
flock
-x
$LOCKFILE
echo
"
$date
,
$is_valid
,
$duration
,
$ftype
,
$workflow
,
$stage
"
>>
"
$STATFILE
"
...
...
@@ -149,13 +155,16 @@ error() {
}
get_mimetype
()
{
filename
=
$1
local
filename
=
$1
local
res
res
=
$(
file
--mime-type
"
$filename
"
|
sed
-e
"s/^.*: //"
)
echo
"
$res
"
}
get_cli_args
()
{
get_cli_args
()
{
local
lines
local
cachedir
while
[[
$#
-gt
0
]]
;
do
case
${
1
}
in
-h
|
--help
)
...
...
@@ -235,10 +244,10 @@ get_cli_args() {
if
[
"
$WITH_PIPE
"
-eq
1
]
;
then
if
[
"
$WITH_DAEMON
"
-eq
1
]
\
||
[
"
$WATCH_FOLDER
"
]
\
||
[
"
$RESULT_FOLDER
"
]
\
||
[
"
$VALID_FOLDER
"
]
\
||
[
"
$INVALID_FOLDER
"
]
\
||
[
-n
"
$WATCH_FOLDER
"
]
\
||
[
-n
"
$RESULT_FOLDER
"
]
\
||
[
-n
"
$VALID_FOLDER
"
]
\
||
[
-n
"
$INVALID_FOLDER
"
]
\
||
[
"
$FILES_MODE
"
=
"sort"
]
\
;
then
error
"param --pipe not combineable with params --daemon, --result-folder, --watch-folder, --valid-folder, --invalid-folder, --files-mode"
...
...
@@ -289,9 +298,11 @@ get_cli_args() {
}
prepare_cmd
()
{
mode
=
$1
ftype
=
$2
stage
=
$3
local
mode
=
$1
local
ftype
=
$2
local
stage
=
$3
local
key
local
cmd
key
=
$(
printf
"%11s%4s%9s"
"
$mode
"
"
$ftype
"
"
$stage
"
|sed
-e
"y/ /_/"
)
debug
"prepare_cmd, key=
$key
"
if
[[
${
validators
[
$key
]
:+1
}
]]
;
then
...
...
@@ -304,7 +315,8 @@ prepare_cmd() {
}
prepare_ftype
()
{
mimetype
=
$1
local
mimetype
=
$1
local
ftype
debug
"prepare_ftype, using mimetype:
$mimetype
"
case
${
mimetype
}
in
"image/tiff"
)
...
...
@@ -323,7 +335,7 @@ prepare_ftype() {
}
estimate_mode
()
{
mimetype
=
$1
local
mimetype
=
$1
debug
"estimate_mode, using mimetype:
$mimetype
"
case
${
mimetype
}
in
"image/tiff"
)
...
...
@@ -338,29 +350,31 @@ estimate_mode() {
;;
esac
debug
"estimate_mode, detected mode:
$MODE
"
echo
$MODE
echo
"
$MODE
"
}
exec_cmd
()
{
cmd
=
$1
ftype
=
$2
workflow
=
$3
stage
=
$4
log
=
$5
local
cmd
=
$1
local
ftype
=
$2
local
workflow
=
$3
local
stage
=
$4
local
log
=
$5
local
start_t
local
stop_t
start_t
=
$(
date
+
"%s"
)
debug
"scan_file, calling cmd='
$cmd
'"
$cmd
>>
"
$log
"
2>&1
is_valid
=
$?
local
is_valid
=
$?
stop_t
=
$(
date
+
"%s"
)
duration
=
$((
stop_t
-
start_t
))
local
duration
=
$((
stop_t
-
start_t
))
debug
"scan_file, duration=
$duration
is_valid=
$is_valid
log=
$log
"
update_statistics
"
$is_valid
"
"
$duration
"
"
$ftype
"
"
$workflow
"
"
$stage
"
echo
"
$is_valid
"
}
handle_input_if_requested
()
{
filename
=
$1
is_valid
=
$2
local
filename
=
$1
local
is_valid
=
$2
debug
"handle_input_if_requested, filename=
$filename
is_valid=
$is_valid
"
if
[
"
$FILES_MODE
"
=
"sort"
]
;
then
if
[
"
$is_valid
"
-eq
0
]
;
then
...
...
@@ -377,7 +391,8 @@ handle_input_if_requested() {
}
get_logfile
()
{
filename
=
$1
local
filename
=
$1
local logname
logname
=
$(
echo
"
$filename
"
|
sed
-e
"s#^
${
WATCH_FOLDER
}
#
${
RESULT_FOLDER
}
#"
-e
"s#
\$
#.log#"
)
debug
"get_logfile, logname=
$logname
(filename=
$filename
)"
echo
"
$logname
"
...
...
@@ -385,7 +400,12 @@ get_logfile() {
scan_file
()
{
filename
=
"
$1
"
local
filename
=
"
$1
"
local
mimetype
local
ftype
local logname
local
cmd
local
is_valid
debug
"scan_file, using filename:
$filename
"
mimetype
=
$(
get_mimetype
"
$filename
"
)
ftype
=
$(
prepare_ftype
"
$mimetype
"
)
...
...
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