[ADD] Launch script: new 'psql' command to enter postgreSQL database

master
Olivier DOSSMANN 2016-02-11 15:25:02 +01:00
parent c5d430ee9b
commit f332f6c32b
1 changed files with 12 additions and 0 deletions

View File

@ -95,6 +95,7 @@ show_help() {
Python dependancies"
echo -e " - migrate Launch migration command:
python manage.py migrate"
echo -e " - psql Enter PSQL database via psql command"
echo -e " - restore dump Restore the given dump"
echo -e " - start [arg ...] Launch Gissmo Docker container
(created by 'create' command) with a name given
@ -118,6 +119,8 @@ check_command() {
return 0
elif test $1 == "init"; then
return 0
elif test $1 == "psql"; then
return 0
elif test $1 == "migrate"; then
return 0
elif test $1 == "restore"; then
@ -261,6 +264,15 @@ test_restore() {
DUMP_DIR="${ARGS%/*}"
}
psql() {
test_postgresql_launched
if [ $? -eq 1 ]; then
$docker_cmd start ${POSTGRES_DOCKER_NAME}
sleep 4 # wait postgreSQL database to be fully launched
fi
$docker_cmd run -it --link ${POSTGRES_DOCKER_NAME}:db --rm postgres sh -c 'exec psql -h "$DB_PORT_5432_TCP_ADDR" -p "$DB_PORT_5432_TCP_PORT" -U postgres' || error_and_quit "Failed to connect to postgreSQL Docker container."
}
restore() {
test_create
test_restore