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
0fb0eb02
Commit
0fb0eb02
authored
10 months ago
by
Andreas Romeyke
Browse files
Options
Downloads
Patches
Plain Diff
- added new param "--single-file"
parent
8381453d
No related branches found
No related tags found
No related merge requests found
Pipeline
#6768
failed
10 months ago
Stage: build-env
Stage: test-tool
Stage: package-tool
Stage: test-package
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/usr/local/bin/validate_workflow.sh
+53
-2
53 additions, 2 deletions
src/usr/local/bin/validate_workflow.sh
with
53 additions
and
2 deletions
src/usr/local/bin/validate_workflow.sh
+
53
−
2
View file @
0fb0eb02
...
...
@@ -58,6 +58,14 @@
#hh -p, --pipe
#hh validates a single filestream from STDIN, writes result to STDOUT
#hh no daemon, no folder nor filemode params needed
#hh -F, --single-file <FILENAME>
#hh validates a single file, writes result to STDOUT
#hh no daemon, no folder nor filemode params needed
#hh
#hh CAUTION: IN GENERAL, DO NOT USE THIS OPTION, USE DAEMON MODE INSTEAD!
#hh
#hh HINT: You MUST set the environment variable $TMPDIR to a dir in same
#hh filesystem as FILENAME exists, because hard links used!
#hh
#hh
...
...
@@ -74,6 +82,7 @@ FILES_MODE_LIST="sort,delete,nothing"
# DEFAULTS
WITH_DAEMON
=
0
WITH_DEBUG
=
0
export
WITH_SINGLE_FILE
=
0
export
WITH_PIPE
=
0
export
STAGE
=
any
export
MODE
=
auto
...
...
@@ -223,7 +232,7 @@ get_mimetype() {
echo_validation_result_if_pipe
()
{
local
is_valid
=
"
$1
"
if
[[
"
${
WITH_PIPE
}
"
-eq
1
]]
;
then
if
[[
"
${
WITH_PIPE
}
"
-eq
1
||
"
${
WITH_SINGLE_FILE
}
"
-eq
1
]]
;
then
echo
"
${
is_valid
}
"
fi
}
...
...
@@ -288,6 +297,12 @@ get_cli_args() {
WITH_PIPE
=
1
shift
;;
-F
|
--single-file
)
WITH_SINGLE_FILE
=
1
FILE_NAME
=
"
$2
"
shift
shift
;;
*
)
error
"'
$1
' is invalid param. Please, give '
$(
basename
"
$0
"
)
--help' a chance!"
exit
1
...
...
@@ -310,11 +325,30 @@ get_cli_args() {
||
[[
-n
"
${
VALID_FOLDER
}
"
]]
\
||
[[
-n
"
${
INVALID_FOLDER
}
"
]]
\
||
[[
"
${
FILES_MODE
}
"
=
"sort"
]]
\
||
[[
-n
"
${
SINGLE_FILE
}
"
]]
\
;
then
error
"param --pipe not combinable with params --daemon, --result-folder, --watch-folder, --valid-folder, --invalid-folder, --files-mode"
exit
1
fi
else
if
[[
"
${
WITH_SINGLE_FILE
}
"
-eq
1
]]
;
then
if
[[
"
${
WITH_DAEMON
}
"
-eq
1
]]
\
||
[[
-n
"
${
WATCH_FOLDER
}
"
]]
\
||
[[
-n
"
${
RESULT_FOLDER
}
"
]]
\
||
[[
-n
"
${
VALID_FOLDER
}
"
]]
\
||
[[
-n
"
${
INVALID_FOLDER
}
"
]]
\
||
[[
"
${
FILES_MODE
}
"
=
"sort"
]]
\
||
[[
"
${
WITH_PIPE
}
"
-ne
0
]]
\
;
then
error
"param --single-file not combinable with params --daemon, --result-folder, --watch-folder, --valid-folder, --invalid-folder, --files-mode"
exit
1
fi
if
[[
!
-f
"
${
FILE_NAME
}
"
]]
;
then
error
"filename '
$FILE_NAME
' for param --single-file does not exist!"
exit
1
fi
else
if
[[
"
${
WITH_DAEMON
}
"
-eq
1
]]
&&
[[
"
${
FILES_MODE
}
"
=
"sort"
]]
;
then
error
"param --daemon does only work with param --mode='delete' or --mode='nothing'!"
exit
1
...
...
@@ -342,6 +376,7 @@ get_cli_args() {
fi
fi
fi
fi
cachedir
=
$(
dirname
"
${
STATFILE
}
"
)
if
[[
!
-d
"
${
cachedir
}
"
]]
;
then
mkdir
-p
"
${
cachedir
}
"
||
error
"Could not create dir
${
cachedir
}
,
$?
"
...
...
@@ -609,7 +644,22 @@ if [[ "${WITH_PIPE}" -eq 1 ]]; then
rm
-f
"
${
filename
}
.log"
||
error
"could not remove temporary file '
${
filename
}
.log'"
rm
-f
"
${
filename
}
"
||
error
"could not remove temporary file '
${
filename
}
'"
exit
"
${
result
}
"
else
else
if
[[
"
${
WITH_SINGLE_FILE
}
"
-eq
1
]]
;
then
#cli mode, use filename
debug
"checking filename '
${
FILE_NAME
}
'"
dirname
=
$(
mktemp
-d
--tmpdir
validate_wrg.XXXX
)
basename
=
$(
basename
"
${
FILE_NAME
}
"
)
filename
=
"
${
dirname
}
/
${
basename
}
"
ln
-t
"
${
dirname
}
"
"
${
FILE_NAME
}
"
result
=
$(
scan_file
"
${
filename
}
"
)
debug
"single-file mode result (is_valid):
${
result
}
"
cat
"
${
filename
}
.log"
rm
-f
"
${
filename
}
.log"
||
error
"could not remove temporary file '
${
filename
}
.log'"
rm
-f
"
${
filename
}
"
||
error
"could not remove temporary file '
${
filename
}
'"
rm
-Rf
"
${
dirname
}
"
||
error
"could not remove temporary dir '
${
dirname
}
'"
exit
"
${
result
}
"
else
if
[[
"
${
WITH_DAEMON
}
"
-eq
1
]]
;
then
# TODO: protect DAEMON from STRG-C for clean shutdown
# echo daemon mode, use inotify to watch changes
...
...
@@ -631,4 +681,5 @@ else
debug
"checking dir
${
WATCH_FOLDER
}
"
scan_dir
"
${
WATCH_FOLDER
}
"
fi
fi
fi
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