From 8690b2897cdc48c4735ad8be63af4a0b30d7a764 Mon Sep 17 00:00:00 2001 From: Olivier DOSSMANN Date: Wed, 13 Jan 2016 10:50:56 +0100 Subject: [PATCH] [IMP] Launch script: read configuration from current directory or XDG_CONFIG_HOME one. --- launch.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/launch.sh b/launch.sh index 2015a50..c99509a 100755 --- a/launch.sh +++ b/launch.sh @@ -15,11 +15,21 @@ POSTGRES_VERSION="9.5" GISSMO_DOCKER_NAME="gissmo" ## User -if ! test -f config; then - echo "'config' file not found. Copy config.example to config one and try again!" - exit 1 +CONFIG_FILENAME="config" +if test -z $XDG_CONFIG_HOME; then + CONFIG_DEFAULT_DIR="${HOME}/.config/gissmo" +else + CONFIG_DEFAULT_DIR="${XDG_CONFIG_HOME}" fi -. config || exit 1 +CONFIG_FILE="${CONFIG_DEFAULT_DIR}/${CONFIG_FILENAME}" +if ! test -f ${CONFIG_FILE}; then + CONFIG_FILE="${PWD}/${CONFIG_FILENAME}" + if ! test -f ${CONFIG_FILE}; then + echo "'config' file not found. Use 'config.example' file and copy it to 'config' one either in ${CONFIG_DEFAULT_DIR} or ${PWD}. Then try again!" + exit 1 + fi +fi +. ${CONFIG_FILE} || exit 1 ## Composed GISSMO_DIR="${PROJECT_DIR}/${GIT_DIR_NAME}"