From 437bc2cdc3afbfcb87598c1a93a3b2b15ffb719a Mon Sep 17 00:00:00 2001 From: Olivier DOSSMANN Date: Thu, 14 Jan 2016 11:24:08 +0100 Subject: [PATCH] [IMP] Launch script: help to use another configuration file to launch multiple instance with different configuration of Gissmo --- launch.sh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/launch.sh b/launch.sh index 202dbcd..014d22f 100755 --- a/launch.sh +++ b/launch.sh @@ -15,17 +15,28 @@ POSTGRES_VERSION="9.5" GISSMO_DOCKER_NAME="gissmo" ## User -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_FILE="${CONFIG_DEFAULT_DIR}/${CONFIG_FILENAME}" -if ! test -f ${CONFIG_FILE}; then - CONFIG_FILE="${PWD}/${CONFIG_FILENAME}" +if test -z "$GISSMO_CFG"; then + # No Gissmo Launcher configuration file given. Search one. + CONFIG_FILENAME="config" + # first in XDG directory, otherwise ~/.config one. + if test -z $XDG_CONFIG_HOME; then + CONFIG_DEFAULT_DIR="${HOME}/.config/gissmo" + else + CONFIG_DEFAULT_DIR="${XDG_CONFIG_HOME}" + fi + CONFIG_FILE="${CONFIG_DEFAULT_DIR}/${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!" + 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 +else + # Gissmo Launcher configuration file is given! Check it. + CONFIG_FILE=$GISSMO_CFG + if ! test -f $CONFIG_FILE; then + echo "Configuration file not found: ${CONFIG_FILE}" exit 1 fi fi @@ -89,6 +100,10 @@ show_help() { echo -e " $PROGRAM stop" echo -e " $PROGRAM start python manage.py shell" echo -e " $PROGRAM stop" + echo "" + echo -e "If GISSMO_CFG used, you can specify another configuration file. Example:" + echo "" + echo -e " GISSMO_CFG=~/new_config $PROGRAM" # TODO: Add clean() command to STOP and DELETE Gissmo Docker container # TODO: Add clean_db() command to STOP and DELETE postgreSQL Docker container # TODO: Add clean_all() command that makes clean() and clean_db()