diff --git a/launch.sh b/launch.sh index d726a5d..d7ab1d1 100755 --- a/launch.sh +++ b/launch.sh @@ -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