Use mktemp to create workspace directory

mktemp is a better idea for security, as well as enabling users to
specify a different directory using the TMPDIR environment variable,
which is useful if /tmp is a small tmpfs.

Also fix a bug where the first few log messages were failing as the
workspace directory wasn't been created early enough.
This commit is contained in:
Nick White 2015-09-10 15:05:07 +01:00
parent c0133ecfa6
commit de789ac8ea
2 changed files with 2 additions and 5 deletions

View File

@ -49,11 +49,8 @@ source `dirname $0`/tesstrain_utils.sh
ARGV=("$@")
parse_flags
tlog "\n=== Starting training for language '${LANG_CODE}'"
tlog "Cleaning workspace directory ${TRAINING_DIR}..."
mkdir -p ${TRAINING_DIR}
rm -fr ${TRAINING_DIR}/*
tlog "\n=== Starting training for language '${LANG_CODE}'"
source `dirname $0`/language-specific.sh
set_lang_specific_parameters ${LANG_CODE}

View File

@ -25,7 +25,7 @@ OUTPUT_DIR="/tmp/tesstrain/tessdata"
OVERWRITE=0
RUN_SHAPE_CLUSTERING=0
EXTRACT_FONT_PROPERTIES=1
WORKSPACE_DIR="/tmp/tesstrain"
WORKSPACE_DIR=`mktemp -d`
EXPOSURES=0
# Logging helper functions.