From f351acebea56076f1a30bbbb46930ca19f7b5c9e Mon Sep 17 00:00:00 2001 From: Daniel <daniel@harvey> Date: Thu, 26 Mar 2020 18:08:03 +0100 Subject: [PATCH] FIX: More strinct error handling, message if commands are not found. --- config.defaults | 9 +++++---- utils/load_settings.sh | 16 +++++++++++----- utils/make_db | 4 ++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/config.defaults b/config.defaults index bd669cb..79e84f4 100644 --- a/config.defaults +++ b/config.defaults @@ -23,13 +23,14 @@ # # Commands # 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. -MYSQLADMIN_CMD=$(command -v mysqladmin) +MYSQLADMIN_CMD=$(command -v mysqladmin || echo "mysqladmin not found!" >&2) # 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. -MYSQL_CONFIG_EDITOR_CMD=$(command -v mysql_config_editor) +MYSQL_CONFIG_EDITOR_CMD=$(command -v mysql_config_editor \ + || echo "mysql_config_editor not found!" >&2) # # MySQL Connection # The host of the MySQL server. diff --git a/utils/load_settings.sh b/utils/load_settings.sh index 9e8d1b7..85d06ad 100644 --- a/utils/load_settings.sh +++ b/utils/load_settings.sh @@ -19,13 +19,19 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. # Load setting from different files, in this order: -# - config.defaults -# - .config +# - config.defaults (in the current directory) +# - .config (in the current directory) # - The file given in ENV_FILE. -[[ -n "config.defaults" ]] && source "config.defaults" -[[ -n ".config" ]] && source ".config" -[[ -n "$ENV_FILE" ]] && source "$ENV_FILE" +if [[ -r "config.defaults" ]] ; then + source "config.defaults" +fi +if [[ -r ".config" ]] ; then + source ".config" +fi +if [[ -n "$ENV_FILE" ]] ; then + source "$ENV_FILE" +fi export MYSQL_CMD export MYSQLDUMP_CMD diff --git a/utils/make_db b/utils/make_db index 652b391..c8b9ae9 100755 --- a/utils/make_db +++ b/utils/make_db @@ -22,6 +22,8 @@ # # ** end header +set -e + INSTALL_SQL_FILE="db_2_0.sql" if [ -z "$UTILSPATH" ]; then @@ -29,8 +31,6 @@ if [ -z "$UTILSPATH" ]; then export UTILSPATH fi -set -e - source $UTILSPATH/load_settings.sh source $UTILSPATH/helpers.sh -- GitLab