17 lines
510 B
Bash
Executable File
17 lines
510 B
Bash
Executable File
#!/bin/bash
|
|
# psql in the pgsql container. Usage: ./psql.sh [database] [user] — defaults: intai intai
|
|
SCRIPT_DIR="$(realpath $(dirname "$(readlink -f "$0")"))"
|
|
|
|
. $SCRIPT_DIR/_docker-cmd.sh || {
|
|
echo "no docker cmd is presented" && exit 1
|
|
}
|
|
|
|
CONTAINER=$(docker ps --filter "label=com.docker.compose.service=pgsql" --format '{{.ID}}' | head -n1)
|
|
|
|
if [[ -z "${CONTAINER}" ]]; then
|
|
echo "Unable to find container: pgsql"
|
|
exit 1
|
|
fi
|
|
|
|
$DOCKER_CMD exec -ti ${CONTAINER} psql -U "${2:-intai}" -d "${1:-intai}"
|