[FIX] Problem with export that is already used by Bash
This commit is contained in:
parent
30126e9daf
commit
3042f5c813
34
launch.sh
34
launch.sh
@ -83,13 +83,13 @@ not_implemented() {
|
|||||||
show_help() {
|
show_help() {
|
||||||
echo "$PROGRAM COMMAND [arg ...]"
|
echo "$PROGRAM COMMAND [arg ...]"
|
||||||
echo -e " Where ${green}COMMAND${reset} is one of:"
|
echo -e " Where ${green}COMMAND${reset} is one of:"
|
||||||
|
echo -e " - backup Create a compressed postgreSQL database dump
|
||||||
|
in current directory"
|
||||||
echo -e " - create Create postgreSQL database volume and
|
echo -e " - create Create postgreSQL database volume and
|
||||||
postgreSQL Docker container"
|
postgreSQL Docker container"
|
||||||
echo -e " - dev [arg ...] Mount Git repository directory AS VOLUME
|
echo -e " - dev [arg ...] Mount Git repository directory AS VOLUME
|
||||||
for Gissmo Docker container and launch it in
|
for Gissmo Docker container and launch it in
|
||||||
'development' mode"
|
'development' mode"
|
||||||
echo -e " - export Create a compressed postgreSQL database dump
|
|
||||||
in current directory"
|
|
||||||
echo -e " - init Create project directory as python virtual
|
echo -e " - init Create project directory as python virtual
|
||||||
environment, fetch git repository and install
|
environment, fetch git repository and install
|
||||||
Python dependancies"
|
Python dependancies"
|
||||||
@ -111,12 +111,12 @@ show_help() {
|
|||||||
|
|
||||||
check_command() {
|
check_command() {
|
||||||
# Allowed commands return 0 to continue. Otherwise show help and exit
|
# Allowed commands return 0 to continue. Otherwise show help and exit
|
||||||
if test $1 == "create"; then
|
if test $1 == "backup"; then
|
||||||
|
return 0
|
||||||
|
elif test $1 == "create"; then
|
||||||
return 0
|
return 0
|
||||||
elif test $1 == "dev"; then
|
elif test $1 == "dev"; then
|
||||||
return 0
|
return 0
|
||||||
elif test $1 == "export"; then
|
|
||||||
return 0
|
|
||||||
elif test $1 == "init"; then
|
elif test $1 == "init"; then
|
||||||
return 0
|
return 0
|
||||||
elif test $1 == "psql"; then
|
elif test $1 == "psql"; then
|
||||||
@ -196,7 +196,7 @@ another name please set GISSMO_DOCKER_NAME in configuration file."
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
test_export() {
|
test_backup() {
|
||||||
# Check postgreSQL Docker container exists and is launched.
|
# Check postgreSQL Docker container exists and is launched.
|
||||||
test_postgresql_launched
|
test_postgresql_launched
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
@ -204,12 +204,12 @@ test_export() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
export_command() {
|
backup() {
|
||||||
# Check all variables are availables
|
# Check all variables are availables
|
||||||
test_create
|
test_create
|
||||||
# Then check some specific things for dump method
|
# Then check some specific things for dump method
|
||||||
test_export
|
test_backup
|
||||||
$docker_cmd run -it --rm --volume $PWD/:/tmp/ --link ${POSTGRES_DOCKER_NAME}:db postgres:${POSTGRES_VERSION} bash -c 'exec pg_dump -F c -h "$DB_PORT_5432_TCP_ADDR" -p "$DB_PORT_5432_TCP_PORT" -U postgres postgres > /tmp/gissmo-`date +"%Y.%m.%d.%H%M"`-'${GISSMO_VERSION}'.dump' || error_and_quit "Failed to export Gissmo database."
|
$docker_cmd run -it --rm --volume $PWD/:/tmp/ --link ${POSTGRES_DOCKER_NAME}:db postgres:${POSTGRES_VERSION} bash -c 'exec pg_dump -F c -h "$DB_PORT_5432_TCP_ADDR" -p "$DB_PORT_5432_TCP_PORT" -U postgres postgres > /tmp/gissmo-`date +"%Y.%m.%d.%H%M"`-'${GISSMO_VERSION}'.dump' || error_and_quit "Failed to backup Gissmo database."
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@ -221,7 +221,7 @@ init() {
|
|||||||
virtualenv -p python3 $PROJECT_DIR || error_and_quit "Create ${PROJECT_DIR} python virtual environment failed."
|
virtualenv -p python3 $PROJECT_DIR || error_and_quit "Create ${PROJECT_DIR} python virtual environment failed."
|
||||||
info "Python virtual environment initialized."
|
info "Python virtual environment initialized."
|
||||||
fi
|
fi
|
||||||
cd $PROJECT_DIR
|
cd "$PROJECT_DIR"
|
||||||
# On Fedora 23: gcc postgresql-devel python3-devel python-virtualenv git-core python3-pip redhat-rpm-config gmp-devel
|
# On Fedora 23: gcc postgresql-devel python3-devel python-virtualenv git-core python3-pip redhat-rpm-config gmp-devel
|
||||||
sudo apt-get install -qq libpq-dev python3-dev python-virtualenv git-core python3-pip || error_and_quit "Dependancies installation failed."
|
sudo apt-get install -qq libpq-dev python3-dev python-virtualenv git-core python3-pip || error_and_quit "Dependancies installation failed."
|
||||||
info "Dependancies via apt-get checked/installed."
|
info "Dependancies via apt-get checked/installed."
|
||||||
@ -236,8 +236,8 @@ init() {
|
|||||||
cp "${GISSMO_DIR}/scripts/git_hooks/pre-commit" "${GISSMO_DIR}/.git/hooks/pre-commit" || error_and_quit "Failed to install pre-commit hook."
|
cp "${GISSMO_DIR}/scripts/git_hooks/pre-commit" "${GISSMO_DIR}/.git/hooks/pre-commit" || error_and_quit "Failed to install pre-commit hook."
|
||||||
info "Git repository pre-commit hook installed."
|
info "Git repository pre-commit hook installed."
|
||||||
fi
|
fi
|
||||||
. bin/activate || error_and_quit "Failed entering python virtual environment"
|
source bin/activate || error_and_quit "Failed entering python virtual environment"
|
||||||
cd $GISSMO_DIR
|
cd "$GISSMO_DIR"
|
||||||
pip install -q -r requirements.txt || error_and_quit "Python dependancies
|
pip install -q -r requirements.txt || error_and_quit "Python dependancies
|
||||||
installation failed."
|
installation failed."
|
||||||
info "Python dependancies checked."
|
info "Python dependancies checked."
|
||||||
@ -294,11 +294,11 @@ test_initial_start() {
|
|||||||
fi
|
fi
|
||||||
# Build Gissmo Docker images if missing
|
# Build Gissmo Docker images if missing
|
||||||
if [[ "$($docker_cmd images -q gissmo:${GISSMO_VERSION} 2> /dev/null)" == "" ]]; then
|
if [[ "$($docker_cmd images -q gissmo:${GISSMO_VERSION} 2> /dev/null)" == "" ]]; then
|
||||||
cd $GISSMO_DIR
|
cd "$GISSMO_DIR"
|
||||||
info "Building Docker images…"
|
info "Building Docker images…"
|
||||||
$docker_cmd build -t gissmo:${GISSMO_VERSION} -f ${DOCKERFILE} . || error_and_quit "Failed to build Gissmo Docker container."
|
$docker_cmd build -t gissmo:${GISSMO_VERSION} -f ${DOCKERFILE} . || error_and_quit "Failed to build Gissmo Docker container."
|
||||||
info "…done."
|
info "…done."
|
||||||
cd $CURRENT_DIR
|
cd "$CURRENT_DIR"
|
||||||
fi
|
fi
|
||||||
if test -z "$GISSMO_DOCKER_PORT"; then
|
if test -z "$GISSMO_DOCKER_PORT"; then
|
||||||
error_and_quit "No Gissmo Docker container port given
|
error_and_quit "No Gissmo Docker container port given
|
||||||
@ -362,13 +362,7 @@ fi
|
|||||||
|
|
||||||
if ! test -z $COMMAND; then
|
if ! test -z $COMMAND; then
|
||||||
check_command "$COMMAND"
|
check_command "$COMMAND"
|
||||||
# To avoid 'export' bash command reassignement which made some failure in
|
|
||||||
#+ Python virtualenv
|
|
||||||
if "$COMMAND" == "export"; then
|
|
||||||
export_command
|
|
||||||
else
|
|
||||||
$COMMAND
|
$COMMAND
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
show_help
|
show_help
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user