#!/bin/sh
#
# Prints the current character encoding of the Scalix DB.
#
# Usage: sxpsql-checkencoding
#

# Pass "" to prevent implicit passing of $*
. /opt/scalix-postgres/bin/common-helpers.sh ""

/etc/init.d/scalix-postgres status >/dev/null 2>/dev/null
POSTGRES_RUNNING=$?

if [ $POSTGRES_RUNNING -ne 0 ]; then
    /etc/init.d/scalix-postgres start
fi

su - -c "$PGENGINE/psql -h $PSQL_DIR -p $PSQL_PORT -c '\l' scalix" postgres |\
    grep 'scalix' |\
    awk -F '|' '{print $NF}' |\
    sed 's/ //g'
