oehrlis / oudbase

OUD base environment scripts
Apache License 2.0
6 stars 1 forks source link

Enhance template with logging and bash checks #81

Closed oehrlis closed 1 year ago

oehrlis commented 4 years ago

The current templates do not provide a central logging nor do they check mandatory parameter. Scripts must be enhanced to include basic checks and a central logging.

similar to the following code

# Define a bunch of bash option see 
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
set -o nounset          # stop script after 1st cmd failed
set -o errexit          # exit when 1st unset variable found
set -o pipefail         # pipefail exit after 1st piped commands failed

readonly LOGFILE="${LOG_BASE}/$(basename ${SCRIPT_NAME} .sh).log"
touch ${LOGFILE} 2>/dev/null
exec 1> >(tee -a "$LOGFILE")
exec 2>&1               # Redirect standard error to standard out 
echo "INFO: Start to build MODS white papers using ${SCRIPT_NAME}" 
oehrlis commented 1 year ago

add basic check for valid variables in v3.0.0