[UP] Launch script so that some line don't take more than 80 chars

master
Olivier DOSSMANN 2016-01-14 14:50:11 +01:00
parent fd70112911
commit 6d97d5e9ac
1 changed files with 32 additions and 20 deletions

View File

@ -28,7 +28,8 @@ if test -z "$GISSMO_CFG"; then
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!"
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
@ -82,21 +83,21 @@ not_implemented() {
show_help() {
echo "$PROGRAM COMMAND [arg ...]"
echo -e " Where ${green}COMMAND${reset} is one of:"
echo -e " - create Create postgreSQL database volume and \\
echo -e " - create Create postgreSQL database volume and \
postgreSQL Docker container"
echo -e " - dev [arg ...] Mount Git repository directory AS VOLUME \\
for Gissmo Docker container and launch it in \\
echo -e " - dev [arg ...] Mount Git repository directory AS VOLUME \
for Gissmo Docker container and launch it in \
'development' mode"
echo -e " - init Create project directory as python virtual \\
environment, fetch git repository and install \\
echo -e " - init Create project directory as python virtual \
environment, fetch git repository and install \
Python dependancies"
echo -e " - migrate Launch migration command: \\
echo -e " - migrate Launch migration command: \
python manage.py migrate"
echo -e " - restore dump Restore the given dump"
echo -e " - start [arg ...] Launch Gissmo Docker container \\
(created by 'create' command) with a name given \\
echo -e " - start [arg ...] Launch Gissmo Docker container \
(created by 'create' command) with a name given \
in GISSMO_DOCKER_NAME variable. args is optional."
echo -e " - stop Stop Gissmo Docker container which name is \\
echo -e " - stop Stop Gissmo Docker container which name is \
GISSMO_DOCKER_NAME variable content"
echo ""
echo "For an example you can use it in this order:"
@ -110,10 +111,13 @@ show_help() {
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 -e "If GISSMO_CFG used, you can specify another configuration file. \
Example:"
echo ""
echo -e " GISSMO_CFG=~/new_config $PROGRAM"
# TODO: Add clean() command with args to: STOP and DELETE Gissmo container, STOP and DELETE postgreSQL container, DELETE dbdata OR do all these thing into one.
# TODO: Add clean() command with args to: STOP and DELETE Gissmo container,
# STOP and DELETE postgreSQL container, DELETE dbdata OR do all these
# things into one.
}
check_command() {
@ -140,7 +144,8 @@ check_command() {
test_docker_cmd() {
if test -z "$docker_cmd"; then
error_and_quit "Docker command not found. Install docker or fill in the PATH."
error_and_quit "Docker command not found. Install docker or fill\
in the PATH."
fi
return 0
}
@ -166,13 +171,16 @@ test_create() {
error_and_quit "No database directory given (DB_DIR in config file)."
fi
if test -z "$DB_VOLUME_NAME"; then
error_and_quit "No database volume name given (DB_VOLUME_NAME in config file)."
error_and_quit "No database volume name given (DB_VOLUME_NAME in \
config file)."
fi
if test -z "$POSTGRES_VERSION"; then
error_and_quit "No postgres version given (POSTGRES_VERSION in config file)."
error_and_quit "No postgres version given (POSTGRES_VERSION in \
config file)."
fi
if test -z "$POSTGRES_DOCKER_NAME"; then
error_and_quit "You need a name for your Docker database container (POSTGRES_DOCKER_NAME in config file)."
error_and_quit "You need a name for your Docker database container \
(POSTGRES_DOCKER_NAME in config file)."
fi
}
@ -190,7 +198,8 @@ dev() {
if [ $? -eq 1 ]; then
$docker_cmd run -it --rm --link ${POSTGRES_DOCKER_NAME}:db -p ${GISSMO_DOCKER_PORT}:8000 -v ${GISSMO_DIR}:/opt/gissmo --name ${GISSMO_DOCKER_NAME} gissmo:${GISSMO_VERSION} ${ARGS:='development'} || error_and_quit "Failed to create and launch ${GISSMO_DOCKER_NAME} container."
else
error_and_quit "${GISSMO_DOCKER_NAME} is already launched! If you need another name please set GISSMO_DOCKER_NAME in configuration file."
error_and_quit "${GISSMO_DOCKER_NAME} is already launched! If you need \
another name please set GISSMO_DOCKER_NAME in configuration file."
fi
}
@ -219,7 +228,8 @@ init() {
fi
. bin/activate || error_and_quit "Failed entering python virtual environment"
cd $GISSMO_DIR
pip install -q -r requirements.txt || error_and_quit "Python dependancies installation failed."
pip install -q -r requirements.txt || error_and_quit "Python dependancies \
installation failed."
info "Python dependancies checked."
deactivate || error_and_quit "Failed exiting python virtual environment."
}
@ -264,7 +274,8 @@ test_initial_start() {
error_and_quit "Docker file don't exists: ${DOCKERFILE}"
fi
if test -z "$GISSMO_DOCKER_PORT"; then
error_and_quit "No Gissmo Docker container port given (GISSMO_DOCKER_PORT in config file)."
error_and_quit "No Gissmo Docker container port given \
(GISSMO_DOCKER_PORT in config file)."
fi
test_postgresql_exists
}
@ -291,7 +302,8 @@ start() {
if [ $? -eq 1 ]; then
$docker_cmd run -it --rm --link ${POSTGRES_DOCKER_NAME}:db -p ${GISSMO_DOCKER_PORT}:8000 -e SECRET_KEY="abcdefg" --name ${GISSMO_DOCKER_NAME} gissmo:${GISSMO_VERSION} $ARGS || error_and_quit "Failed to create and launch ${GISSMO_DOCKER_NAME} container."
else
error_and_quit "${GISSMO_DOCKER_NAME} is already launched! If you need another name please set GISSMO_DOCKER_NAME in configuration file."
error_and_quit "${GISSMO_DOCKER_NAME} is already launched! If you need \
another name please set GISSMO_DOCKER_NAME in configuration file."
fi
}