DEBUG=false info () { echo >&2 " * $*" ; } debug () { ! ${DEBUG} || echo >&2 " ~ $*" ; } error () { echo >&2 "ERROR: $*" ; false ; } get_image_id () { local old_IFS=$IFS local result # split "$1" into "$1 $2 .." on colons IFS=: set -- $1 IFS=$old_IFS case $2 in local) # Default to $IMAGE_NAME if it is set since .image-id might not exist echo "${IMAGE_NAME-$(cat "$1"/.image-id)}" ;; remote) local version=${1//\./} case $OS in rhel7) ns=rhscl if test "$version" -le 92; then ns=openshift3 fi image=registry.access.redhat.com/$ns/postgresql-${version}-rhel7 ;; centos7) ns=centos if test "$version" -le 92; then ns=openshift fi local image=docker.io/$ns/postgresql-${1//\./}-centos7 ;; esac docker pull "$image" >/dev/null echo "$image" ;; esac } data_pagila_create () { debug "initializing pagila database" CID="$CID" ./test/pagila.sh } data_pagila_check () { debug "doing pagila check" local exp_output='28 16 2' local output=$(docker exec -i "$CID" container-entrypoint psql -tA </dev/null </dev/null || :") case $output in 1*) return ;; "") ;; *) echo "$output" ; false ;; esac sleep 1 counter=$(( counter + 1 )) done } # version2number VERSION [DEPTH] [WIDTH] # -------------------------------------- version2number () { local old_IFS=$IFS local to_print= depth=${2-3} width=${3-2} sum=0 one_part IFS='.' set -- $1 while test $depth -ge 1; do depth=$(( depth - 1 )) part=${1-0} ; shift || : printf "%0${width}d" "$part" done IFS=$old_IFS } # container_ip CONTAINER_ID # ------------------------- container_ip() { docker inspect --format='{{.NetworkSettings.IPAddress}}' "$1" } # vi: set ft=sh