Skip to content
Snippets Groups Projects
Unverified Commit f93a3735 authored by Daniel's avatar Daniel
Browse files

FIX: Runs in Docker again.

Also:

- More strict `set -e`
- Global path variables.
- A few more comments
- Copyright notices

== Technically, this is a big squash merge: ===

Squashed commit of the following:

commit 5c26e223e78192ba3d788ab2c640e8c3a1c73866
Author: Daniel <daniel@harvey>
Date:   Fri Mar 27 13:11:43 2020 +0100

    MAINT: No warning if mysql_config_editor can not be found.

commit 06c3f1d25e3bd1a37942f7f0630daac82c8a7738
Author: Daniel <daniel@harvey>
Date:   Fri Mar 27 12:57:15 2020 +0100

    MAINT: Moved `set -e` more to the front.

commit 68ad8469e0dd8c5dc3c4d93f41b4902e622f579f
Author: Daniel <daniel@harvey>
Date:   Fri Mar 27 12:56:37 2020 +0100

    MAINT: Removed debugging output, added copyright lines.

commit 7ed57cdaf1d1299b5cb8d412988409410eee9b45
Author: Daniel <daniel@harvey>
Date:   Fri Mar 27 11:59:37 2020 +0100

    MAINT: moved MAINPATH definition into load_settings.sh

commit b34f82812a59e8913d40d71c3ae34f3f0106fdf2
Author: Daniel <daniel@harvey>
Date:   Fri Mar 27 10:59:57 2020 +0100

    MAINT: A bit of cleanup.

commit 4a88516991f39091edf628bcad066b6873b347c0
Author: Daniel <daniel@harvey>
Date:   Fri Mar 27 09:35:16 2020 +0100

    STY: Whitespace fixup.

commit 4724ee70
Author: Henrik tom Wörden <henrik@trineo.org>
Date:   Fri Mar 27 08:22:53 2020 +0100

    FIX: added missing env setting in applypatches

commit 1d797300
Author: Henrik tom Wörden <henrik@trineo.org>
Date:   Fri Mar 27 08:18:47 2020 +0100

    MAINT: make calling skripts more cwd independent

commit c908d69b
Author: Daniel <daniel@harvey>
Date:   Thu Mar 26 19:48:58 2020 +0100

    MAINT: Failing fast if no SQL is found.

commit 2fa7d1bb
Author: Daniel <daniel@harvey>
Date:   Thu Mar 26 19:26:57 2020 +0100

    Debug

commit a520f4a2
Author: Daniel <daniel@harvey>
Date:   Thu Mar 26 19:22:48 2020 +0100

    Debug

commit fb60953d
Author: Daniel <daniel@harvey>
Date:   Thu Mar 26 19:10:56 2020 +0100

    FIX: Loading load_settings.sh

commit d1768287
Author: Daniel <daniel@harvey>
Date:   Thu Mar 26 19:01:40 2020 +0100

    DBG .

commit b1c5d47c
Author: Daniel <daniel@harvey>
Date:   Thu Mar 26 18:55:21 2020 +0100

    FIX: Load definitions first.

commit ed5c4d9c
Author: Daniel <daniel@harvey>
Date:   Thu Mar 26 18:44:03 2020 +0100

    DBG

commit 0763ef3a
Author: Daniel <daniel@harvey>
Date:   Thu Mar 26 18:19:40 2020 +0100

    FIX: Set UTILSPATH in applyPatches.sh

commit f351aceb
Author: Daniel <daniel@harvey>
Date:   Thu Mar 26 18:08:03 2020 +0100

    FIX: More strinct error handling, message if commands are not found.

commit 0338357e
Author: Daniel <daniel@harvey>
Date:   Thu Mar 26 17:26:04 2020 +0100

    DBG .

commit 8f0545c2
Author: Daniel <daniel@harvey>
Date:   Thu Mar 26 16:46:15 2020 +0100

    MAINT: Earlier set -e, also documentation.
parent e68951af
No related branches found
No related tags found
No related merge requests found
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
# # Commands # # Commands
# The MySQL client program. # The MySQL client program.
MYSQL_CMD=$(command -v mysql) MYSQL_CMD=$(command -v mysql || echo "mysql not found!" >&2)
# The mysqladmin program which comes with the MySQL client. # The mysqladmin program which comes with the MySQL client.
MYSQLADMIN_CMD=$(command -v mysqladmin) MYSQLADMIN_CMD=$(command -v mysqladmin || echo "mysqladmin not found!" >&2)
# The mysqldump program which comes with the MySQL client. # The mysqldump program which comes with the MySQL client.
MYSQLDUMP_CMD=$(command -v mysqldump) MYSQLDUMP_CMD=$(command -v mysqldump || echo "mysqldump not found!" >&2)
# The mysql_config_editor program which is used to store the credentials. # The mysql_config_editor program which is used to store the credentials.
MYSQL_CONFIG_EDITOR_CMD=$(command -v mysql_config_editor) MYSQL_CONFIG_EDITOR_CMD=$(command -v mysql_config_editor || true)
# # MySQL Connection # # MySQL Connection
# The host of the MySQL server. # The host of the MySQL server.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
# Copyright (C) 2018 Research Group Biomedical Physics, # Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen # Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com> # Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com>
# Copyright (C) 2020 Daniel Hornung <d.hornung@indiscale.com>
# Copyright (C) 2020 IndiScale <info@indiscale.com> # Copyright (C) 2020 IndiScale <info@indiscale.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
...@@ -24,8 +25,20 @@ ...@@ -24,8 +25,20 @@
# ** end header # ** end header
# #
#apply all available patches. ###############################################################################
# Apply all available patches #
###############################################################################
set -e set -e
if [ -z "$UTILSPATH" ]; then
UTILSPATH=$(realpath "$(dirname $0)/../utils")
export UTILSPATH
fi
source $UTILSPATH/load_settings.sh
source $UTILSPATH/helpers.sh
PATCHES="./patch*/patch.sh" PATCHES="./patch*/patch.sh"
for p in $PATCHES for p in $PATCHES
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
# #
# Copyright (C) 2018 Research Group Biomedical Physics, # Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen # Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright (C) 2020 Daniel Hornung <d.hornung@indiscale.com>
# Copyright (C) 2020 IndiScale <info@indiscale.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
...@@ -24,7 +26,6 @@ ...@@ -24,7 +26,6 @@
# Dump a database with all procedures, permissions, structure and data # Dump a database with all procedures, permissions, structure and data
if [ -z "$UTILSPATH" ]; then if [ -z "$UTILSPATH" ]; then
UTILSPATH="$(realpath $(dirname $0))" UTILSPATH="$(realpath $(dirname $0))"
export UTILSPATH export UTILSPATH
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
# #
# Copyright (C) 2018 Research Group Biomedical Physics, # Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen # Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright 2019 Daniel Hornung # Copyright (C) 2019, 2020 Daniel Hornung (d.hornung@indiscale.com)
# Copyright 2020 Henrik tom Wörden, IndiScale GmbH # Copyright (C) 2020 Henrik tom Wörden
# Copyright (C) 2020 IndiScale GmbH <info@indiscale.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
...@@ -19,15 +20,25 @@ ...@@ -19,15 +20,25 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # 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 { function mysql_execute {
#TODO is it meaningful that here always the database user is used??? #TODO is it meaningful that here always the database user is used???
set +e set -e
$MYSQL_CMD $(get_db_args) -e "$1" $MYSQL_CMD $(get_db_args) -e "$1"
ret=${PIPESTATUS[0]} ret=${PIPESTATUS[0]}
if [ "$ret" -ne 0 ]; then if [ "$ret" -ne 0 ]; then
failure "MYSQL ERROR" failure "MYSQL ERROR"
fi fi
set -e
} }
function get_mysql_args { function get_mysql_args {
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
# #
# Copyright (C) 2018 Research Group Biomedical Physics, # Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen # Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright 2019 Daniel Hornung # Copyright (C) 2019, 2020 Daniel Hornung (d.hornung@indiscale.com)
# Copyright 2020 Henrik tom Wörden, IndiScale GmbH # Copyright (C) 2020 Henrik tom Wörden
# Copyright (C) 2020 IndiScale GmbH <info@indiscale.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
...@@ -18,9 +19,33 @@ ...@@ -18,9 +19,33 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
[[ -n "config.defaults" ]] && source "config.defaults" # Load setting from different files, in this order:
[[ -n ".config" ]] && source ".config" # - config.defaults (in the current directory)
[[ -n "$ENV_FILE" ]] && source "$ENV_FILE" # - .config (in the current directory)
# - The file given in ENV_FILE.
if [ -z "$MAINPATH" ]; then
if [ -z "$UTILSPATH" ] ; then
echo "At least one of MAINPATH and UTILSPATH must be defined in load_settings.sh" >&2
exit 1
fi
MAINPATH="$(dirname $UTILSPATH)"
export MAINPATH
fi
source "$MAINPATH/config.defaults"
if [[ -r "$MAINPATH/.config" ]] ; then
source "$MAINPATH/.config"
fi
if [[ -n "$ENV_FILE" ]] ; then
source "$ENV_FILE"
fi
if [[ -z "$MYSQL_CMD" ]] ; then
echo "'mysql' executable not defined!"
exit 1
fi
export MYSQL_CMD export MYSQL_CMD
export MYSQLDUMP_CMD export MYSQLDUMP_CMD
......
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
# ** header v3.0 # ** header v3.0
# This file is a part of the CaosDB Project. # This file is a part of the CaosDB Project.
# #
# Copyright (C) 2019 Daniel Hornung, Göttingen # Copyright (C) 2019, 2020 Daniel Hornung <d.hornung@indiscale.com>
# Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com> # Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com>
# Copyright (C) 2020 Henrik tom Wörden <h.tomwoerden@indiscale.com>
# Copyright (C) 2020 IndiScale <info@indiscale.com> # Copyright (C) 2020 IndiScale <info@indiscale.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
...@@ -22,6 +23,8 @@ ...@@ -22,6 +23,8 @@
# #
# ** end header # ** end header
set -e
INSTALL_SQL_FILE="db_2_0.sql" INSTALL_SQL_FILE="db_2_0.sql"
if [ -z "$UTILSPATH" ]; then if [ -z "$UTILSPATH" ]; then
...@@ -32,13 +35,6 @@ fi ...@@ -32,13 +35,6 @@ fi
source $UTILSPATH/load_settings.sh source $UTILSPATH/load_settings.sh
source $UTILSPATH/helpers.sh source $UTILSPATH/helpers.sh
set -e
function fail() {
echo "Some error occured, exiting."
exit 1
}
UNITTEST_DATABASE=${UNITTEST_DATABASE-_caosdb_schema_unit_tests} UNITTEST_DATABASE=${UNITTEST_DATABASE-_caosdb_schema_unit_tests}
# optional parameter: [--fresh] for installing a fresh data base. Otherwise an existing one would be reused. # optional parameter: [--fresh] for installing a fresh data base. Otherwise an existing one would be reused.
...@@ -48,7 +44,7 @@ function runtests() { ...@@ -48,7 +44,7 @@ function runtests() {
_install_unit_test_database $@ _install_unit_test_database $@
_execute_tests || ( echo "[FAILURE]" && exit 1 ) _execute_tests || ( failure )
echo "[PASS]" echo "[PASS]"
} }
...@@ -114,7 +110,8 @@ function _setup_mytap() { ...@@ -114,7 +110,8 @@ function _setup_mytap() {
function setup_os() { function setup_os() {
# - mariadb-client :: For SQL server configuration. # - mariadb-client :: For SQL server configuration.
PACKAGES="git PACKAGES="
git
make make
mariadb-client mariadb-client
maven maven
...@@ -124,7 +121,8 @@ function setup_os() { ...@@ -124,7 +121,8 @@ function setup_os() {
unzip unzip
" "
# - vim :: For debugging # - vim :: For debugging
PACKAGES+="vim PACKAGES+="
vim
" "
apt-get update apt-get update
apt-get dist-upgrade -y apt-get dist-upgrade -y
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
# #
# Copyright (C) 2018 Research Group Biomedical Physics, # Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen # Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright 2019 Daniel Hornung # Copyright (C) 2019, 2020 Daniel Hornung <d.hornung@indiscale.com>
# Copyright (C) 2020 Henrik tom Wörden <h.tomwoerden@indiscale.com>
# Copyright (C) 2020 IndiScale <info@indiscale.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
...@@ -21,10 +23,16 @@ ...@@ -21,10 +23,16 @@
# #
# ** end header # ** end header
# #
#header for patch scripts
###############################################################################
# header for patch scripts #
###############################################################################
set -e
# load useful functions ####################################################### # load useful functions #######################################################
. $UTILSPATH/helpers.sh source $UTILSPATH/load_settings.sh
source $UTILSPATH/helpers.sh
USAGE="$1 [ --env=ENV_FILE ] [ --patch=PATCH ] [ --backupdir=BACKUPDIR ]\n\n" USAGE="$1 [ --env=ENV_FILE ] [ --patch=PATCH ] [ --backupdir=BACKUPDIR ]\n\n"
CMD_OPTIONS=$(cat <<EOF CMD_OPTIONS=$(cat <<EOF
...@@ -56,7 +64,6 @@ configuration make file. Notable examples are: ...@@ -56,7 +64,6 @@ configuration make file. Notable examples are:
EOF EOF
) )
set -e
function _print_help() { function _print_help() {
echo -e "$USAGE" echo -e "$USAGE"
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
# #
# Copyright (C) 2018 Research Group Biomedical Physics, # Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen # Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright (C) 2020 Daniel Hornung <d.hornung@indiscale.com>
# Copyright (C) 2020 Henrik tom Wörden <h.tomwoerden@indiscale.com>
# Copyright (C) 2020 IndiScale <info@indiscale.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
...@@ -24,10 +27,17 @@ ...@@ -24,10 +27,17 @@
# Updates all SQL procedures # Updates all SQL procedures
set -e
if [ -z "$UTILSPATH" ]; then
UTILSPATH=$(realpath "$(dirname $0)")
export UTILSPATH
fi
source $UTILSPATH/load_settings.sh
source $UTILSPATH/helpers.sh source $UTILSPATH/helpers.sh
echo -n "updating rules ... " echo -n "updating rules ... "
set -e
mysql_execute "$(sed s/db_2_0/$DATABASE_NAME/g rules.sql)" mysql_execute "$(sed s/db_2_0/$DATABASE_NAME/g rules.sql)"
echo "OK" echo "OK"
...@@ -35,5 +45,3 @@ echo "OK" ...@@ -35,5 +45,3 @@ echo "OK"
echo -n "updating procedures ... " echo -n "updating procedures ... "
mysql_execute "$(sed s/db_2_0/$DATABASE_NAME/g procedures/*.sql procedures/query/*.sql)" mysql_execute "$(sed s/db_2_0/$DATABASE_NAME/g procedures/*.sql procedures/query/*.sql)"
echo "OK" echo "OK"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment