Skip to content
Snippets Groups Projects
Commit f86cf205 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

Merge branch 's-clean-up-stage' into f-new-tools

parents 084a0240 bac0a91e
Branches
Tags
No related merge requests found
......@@ -6,6 +6,7 @@
# Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# 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>
#
# This program is free software: you can redistribute it and/or modify
......@@ -33,8 +34,6 @@ set -e
if [ -z "$UTILSPATH" ]; then
UTILSPATH=$(realpath "$(dirname $0)/../utils")
export UTILSPATH
MAINPATH="$(dirname $UTILSPATH)"
export MAINPATH
fi
source $UTILSPATH/load_settings.sh
......
......@@ -5,6 +5,8 @@
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# 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
# it under the terms of the GNU Affero General Public License as
......@@ -27,8 +29,6 @@
if [ -z "$UTILSPATH" ]; then
UTILSPATH="$(realpath $(dirname $0))"
export UTILSPATH
MAINPATH="$(dirname $UTILSPATH)"
export MAINPATH
fi
# The directory which the dump is to be stored to. Do not change it here. Use
......@@ -45,14 +45,30 @@ function backup() {
database="$1"
backupdir="$2"
<<<<<<< HEAD
# Assert backup dir
mkdir -p "$backupdir"
datastring=$(date -u --rfc-3339=ns | sed 's/ /T/g')
backupfile=${BACKUPDIR}/${DATABASE_NAME}.${datastring}.dump.sql
=======
shift 2
# parameters: connection, database, outfile
if [ -e "$NARG_FILE" ]; then
failure "dumpfile already exists."
fi
echo "Dumping database $NARG_NAME to $NARG_FILE ... "
$MYSQLDUMP_CMD $(get_mysql_args_nodb) $* --opt --default-character-set=utf8 --routines \
"$NARG_NAME" > "$NARG_FILE"
>>>>>>> s-clean-up-stage
if [ -e "$backupfile" ]; then
failure "dumpfile already exists."
fi
<<<<<<< HEAD
=======
success
}
>>>>>>> s-clean-up-stage
echo "Dumping database $database to $backupfile ... "
$MYSQLDUMP_CMD $(get_mysql_args_nodb) --opt --default-character-set=utf8\
......
......@@ -2,8 +2,9 @@
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright 2019, 2020 Daniel Hornung
# Copyright 2020 Henrik tom Wörden, IndiScale GmbH
# Copyright (C) 2019, 2020 Daniel Hornung (d.hornung@indiscale.com)
# 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
# it under the terms of the GNU Affero General Public License as
......@@ -32,14 +33,12 @@
function mysql_execute {
#TODO is it meaningful that here always the database user is used???
set +e
# env | sort
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 {
......
......@@ -2,8 +2,9 @@
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright 2019 Daniel Hornung
# Copyright 2020 Henrik tom Wörden, IndiScale GmbH
# Copyright (C) 2019, 2020 Daniel Hornung (d.hornung@indiscale.com)
# 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
# it under the terms of the GNU Affero General Public License as
......@@ -23,29 +24,34 @@
# - .config (in the current directory)
# - The file given in ENV_FILE.
if [ "$MAINPATH" ]; then
pushd "$MAINPATH" > /dev/null
pushed=1
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
if [[ -r "config.defaults" ]] ; then
source "config.defaults"
MAINPATH="$(dirname $UTILSPATH)"
export MAINPATH
fi
if [[ -r ".config" ]] ; then
source ".config"
# Make a backup of the important environment variables.
my_env=$(export -p | grep -E '(MYSQL|DATABASE)')
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 not defined!"
echo "'mysql' executable not defined!"
exit 1
fi
if [ $pushed ]; then
popd > /dev/null
fi
# Restore backup.
eval "$my_env"
export MYSQL_CMD
export MYSQLDUMP_CMD
......
......@@ -3,8 +3,9 @@
# ** header v3.0
# 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 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
......@@ -29,18 +30,11 @@ INSTALL_SQL_FILE="db_2_0.sql"
if [ -z "$UTILSPATH" ]; then
UTILSPATH="$(realpath $(dirname $0))"
export UTILSPATH
MAINPATH="$(dirname $UTILSPATH)"
export MAINPATH
fi
source $UTILSPATH/load_settings.sh
source $UTILSPATH/helpers.sh
function fail() {
echo "Some error occured, exiting."
exit 1
}
UNITTEST_DATABASE=${UNITTEST_DATABASE-_caosdb_schema_unit_tests}
# optional parameter: [--fresh] for installing a fresh data base. Otherwise an existing one would be reused.
......@@ -50,7 +44,7 @@ function runtests() {
_install_unit_test_database $@
_execute_tests || ( echo "[FAILURE]" && exit 1 )
_execute_tests || ( failure )
echo "[PASS]"
}
......@@ -103,7 +97,7 @@ function _setup_mytap() {
echo MyTAB framework is already installed [OK]
return 0
fi
echo -n "Installing MyTAB framework ... "
echo -n "Installing MyTAP framework ... "
pushd libs > /dev/null
unzip -u mytap*.zip > /dev/null
pushd mytap*/ > /dev/null
......@@ -111,7 +105,7 @@ function _setup_mytap() {
popd > /dev/null
rm -r mytap*/
popd > /dev/null
echo [DONE]
echo "[DONE]"
}
function install_db() {
......
......@@ -4,7 +4,9 @@
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# 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
# it under the terms of the GNU Affero General Public License as
......@@ -21,7 +23,12 @@
#
# ** end header
#
#header for patch scripts
###############################################################################
# header for patch scripts #
###############################################################################
set -e
# load useful functions #######################################################
source $UTILSPATH/load_settings.sh
......@@ -57,7 +64,6 @@ configuration make file. Notable examples are:
EOF
)
set -e
function _print_help() {
echo -e "$USAGE"
......
......@@ -5,6 +5,9 @@
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# 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
# it under the terms of the GNU Affero General Public License as
......@@ -24,18 +27,17 @@
# Updates all SQL procedures
set -e
if [ -z "$UTILSPATH" ]; then
UTILSPATH=$(realpath "$(dirname $0)")
export UTILSPATH
MAINPATH="$(dirname $UTILSPATH)"
export MAINPATH
fi
source $UTILSPATH/helpers.sh
source $UTILSPATH/load_settings.sh
source $UTILSPATH/helpers.sh
echo -n "updating rules ... "
set -e
mysql_execute "$(sed s/db_2_0/$DATABASE_NAME/g rules.sql)"
echo "OK"
......@@ -43,5 +45,3 @@ echo "OK"
echo -n "updating procedures ... "
mysql_execute "$(sed s/db_2_0/$DATABASE_NAME/g procedures/*.sql procedures/query/*.sql)"
echo "OK"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment