#!/bin/sh

set -e

export LC_ALL=C.UTF-8
export LANG=C.UTF-8

if [ $(id -u) -eq 0 ]
then
        # required so that the postgres user can create files
        chmod 777 .
        chmod 777 features
        SU='su postgres -p -c'
else
        SU='bash -c'
fi

for PG_VERSION in /usr/lib/postgresql/*; do
	$SU "PATH=/usr/lib/postgresql/$(basename ${PG_VERSION})/bin:$PATH behave"
done
