diff --git a/utils/helpers.sh b/utils/helpers.sh index 5762301669c5cdd43a2faab0a31e7ffb48915cc4..90115af6fca18f7f6d9ed4719eb6289b3db872f7 100644 --- a/utils/helpers.sh +++ b/utils/helpers.sh @@ -2,7 +2,7 @@ # # Copyright (C) 2018 Research Group Biomedical Physics, # Max-Planck-Institute for Dynamics and Self-Organization Göttingen -# Copyright 2019 Daniel Hornung +# Copyright 2019, 2020 Daniel Hornung # Copyright 2020 Henrik tom Wörden, IndiScale GmbH # # This program is free software: you can redistribute it and/or modify @@ -19,16 +19,26 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. + +############################################################################### +# Helper function definitions # +############################################################################### + +# When sourcing this file, the following variables must be set: +# +# MYSQL_CMD : source $UTILSPATH/load_settings.sh + + + function mysql_execute { #TODO is it meaningful that here always the database user is used??? set +e - env - $MYSQL_CMD $(get_db_args) -e "$1" - ret=${PIPESTATUS[0]} - if [ "$ret" -ne 0 ]; then - failure "MYSQL ERROR" - fi - set -e + $MYSQL_CMD $(get_db_args) -e "$1" + ret=${PIPESTATUS[0]} + if [ "$ret" -ne 0 ]; then + failure "MYSQL ERROR" + fi + set -e } function get_mysql_args { diff --git a/utils/update_sql_procedures.sh b/utils/update_sql_procedures.sh index 73f6bacc86c80bc5b1be83e2c9c762777f99e878..e363a7def525dc602cd5830156dc36b91b2baf4e 100755 --- a/utils/update_sql_procedures.sh +++ b/utils/update_sql_procedures.sh @@ -24,7 +24,13 @@ # Updates all SQL procedures +if [ -z "$UTILSPATH" ]; then + UTILSPATH=$(realpath "$(dirname $0)") + export UTILSPATH +fi + source $UTILSPATH/helpers.sh +source $UTILSPATH/load_settings.sh echo -n "updating rules ... " set -e