diff --git a/Makefile b/Makefile index b7b843e..34e9284 100644 --- a/Makefile +++ b/Makefile @@ -89,17 +89,18 @@ $(DATA)/testdata-presentation: test: test-production test-presentation # run synchronous (without ActiveMQ) +test-production: SCRIPT = process_images.sh --proc-id 1 --lang deu --script Fraktur test-production: $(DATA)/testdata-production ifeq ($(NETWORK),bridge) - ssh -i $(PRIVATE) -Tn -p $(PORT) ocrd@localhost for_production.sh --proc-id 1 --lang deu --script Fraktur $(1)); then - logger -p user.error -t $TASK "invalid extra arguments $*" - exit 1 - fi -} - -source ocrd_lib.sh - -init "$@" - -# run the workflow script on the Controller non-interactively and log its output locally -# subsequently validate and postprocess the results -# do all this in a subshell in the background, so we can return immediately -( - init_task - - pre_clone_to_workdir - - pre_sync_workdir - - ocrd_exec ocrd_enter_workdir ocrd_validate_workflow ocrd_process_workflow - - post_sync_workdir - - post_validate_workdir - - post_process_to_mets - - close_task - -) |& tee -a $WORKDIR/ocrd.log | logger -p user.info -t $TASK &>/dev/null & # without output redirect, ssh will not close the connection upon exit, cf. #9 - -close diff --git a/for_presentation.sh b/for_presentation.sh new file mode 120000 index 0000000..395b02e --- /dev/null +++ b/for_presentation.sh @@ -0,0 +1 @@ +process_mets.sh \ No newline at end of file diff --git a/for_production.sh b/for_production.sh deleted file mode 100755 index 4bf6194..0000000 --- a/for_production.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash -# OCR-D task to be run as OCR script step by Kitodo.Production -# To be called (after copying images to directory) via Manager, e.g.: -# ssh -Tn -p 9022 ocrd@ocrd-manager for_production.sh \ -# --lang deu --script Fraktur \ -# --img-subdir images --ocr-subdir ocr/alto \ -# --task-id 501543 --proc-id 3 \ -# /home/goobi/work/daten/501543 -# full CLI options: see --help - -set -Eeu -set -o pipefail - -parse_args() { - LANGUAGE= - SCRIPT= - PROCESS_ID= - TASK_ID= - WORKFLOW=ocr-workflow-default.sh - IMAGES_SUBDIR=images - RESULT_SUBDIR=ocr/alto - while (($#)); do - case "$1" in - --help|-h) cat <1)); then - logger -p user.error -t $TASK "invalid extra arguments $*" - exit 1 - fi -} - -source ocrd_lib.sh - -init "$@" - -# run the workflow script on the Controller non-interactively and log its output locally -# subsequently validate and postprocess the results -# do all this in a subshell in the background, so we can return immediately -( - init_task - - pre_process_to_workdir - - pre_sync_workdir - - ocrd_exec ocrd_import_workdir ocrd_validate_workflow ocrd_process_workflow - - post_sync_workdir - - post_validate_workdir - - post_process_to_procdir - - close_task - -) |& tee -a $WORKDIR/ocrd.log | logger -p user.info -t $TASK &>/dev/null & # without output redirect, ssh will not close the connection upon exit, cf. #9 - -close diff --git a/for_production.sh b/for_production.sh new file mode 120000 index 0000000..fc6c5f2 --- /dev/null +++ b/for_production.sh @@ -0,0 +1 @@ +process_images.sh \ No newline at end of file diff --git a/process_images.sh b/process_images.sh new file mode 100755 index 0000000..4bf6194 --- /dev/null +++ b/process_images.sh @@ -0,0 +1,103 @@ +#!/bin/bash +# OCR-D task to be run as OCR script step by Kitodo.Production +# To be called (after copying images to directory) via Manager, e.g.: +# ssh -Tn -p 9022 ocrd@ocrd-manager for_production.sh \ +# --lang deu --script Fraktur \ +# --img-subdir images --ocr-subdir ocr/alto \ +# --task-id 501543 --proc-id 3 \ +# /home/goobi/work/daten/501543 +# full CLI options: see --help + +set -Eeu +set -o pipefail + +parse_args() { + LANGUAGE= + SCRIPT= + PROCESS_ID= + TASK_ID= + WORKFLOW=ocr-workflow-default.sh + IMAGES_SUBDIR=images + RESULT_SUBDIR=ocr/alto + while (($#)); do + case "$1" in + --help|-h) cat <1)); then + logger -p user.error -t $TASK "invalid extra arguments $*" + exit 1 + fi +} + +source ocrd_lib.sh + +init "$@" + +# run the workflow script on the Controller non-interactively and log its output locally +# subsequently validate and postprocess the results +# do all this in a subshell in the background, so we can return immediately +( + init_task + + pre_process_to_workdir + + pre_sync_workdir + + ocrd_exec ocrd_import_workdir ocrd_validate_workflow ocrd_process_workflow + + post_sync_workdir + + post_validate_workdir + + post_process_to_procdir + + close_task + +) |& tee -a $WORKDIR/ocrd.log | logger -p user.info -t $TASK &>/dev/null & # without output redirect, ssh will not close the connection upon exit, cf. #9 + +close diff --git a/process_mets.sh b/process_mets.sh new file mode 100755 index 0000000..6c7507e --- /dev/null +++ b/process_mets.sh @@ -0,0 +1,97 @@ +#!/bin/bash +# OCR-D task to be run as OCR script step by Kitodo.Presentation +# To be called (after copying METS file) via Manager, e.g.: +# ssh -Tn -p 9022 ocrd@ocrd-manager for_presentation.sh \ +# --img-grp ORIGINAL --ocr-grp FULLTEXT \ +# --pages PHYS_0010..PHYS_0999 --workflow myocr.sh \ +# /home/goobi/work/daten/501543/mets.xml +# full CLI options: see --help + +set -Eeu +set -o pipefail + +parse_args() { + LANGUAGE= + SCRIPT= + PROCESS_ID= + TASK_ID= + WORKFLOW=ocr-workflow-default.sh + PAGES= + IMAGES_GRP=DEFAULT + RESULT_GRP=FULLTEXT + URL_PREFIX= + while (($#)); do + case "$1" in + --help|-h) cat <1)); then + logger -p user.error -t $TASK "invalid extra arguments $*" + exit 1 + fi +} + +source ocrd_lib.sh + +init "$@" + +# run the workflow script on the Controller non-interactively and log its output locally +# subsequently validate and postprocess the results +# do all this in a subshell in the background, so we can return immediately +( + init_task + + pre_clone_to_workdir + + pre_sync_workdir + + ocrd_exec ocrd_enter_workdir ocrd_validate_workflow ocrd_process_workflow + + post_sync_workdir + + post_validate_workdir + + post_process_to_mets + + close_task + +) |& tee -a $WORKDIR/ocrd.log | logger -p user.info -t $TASK &>/dev/null & # without output redirect, ssh will not close the connection upon exit, cf. #9 + +close