Scripts/sxpsql-checkencoding

From Scalix Wiki
Jump to: navigation, search

sxpsql-checkencoding

#!/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 | grep 'is running' >/dev/null 2>/dev/null
if [ $? = "0" ]; then
    POSTGRES_RUNNING=1
else
    POSTGRES_RUNNING=0
fi

if [ $POSTGRES_RUNNING -ne 1 ]; 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'