# Set data directory and redirect startup output to /var/log/pgsql
mkdir -p $(dirname $postgresql_sysconfig)
touch $postgresql_sysconfig
# Set data directory and redirect startup output to /var/log/pgsql
mkdir -p $(dirname $postgresql_sysconfig)
touch $postgresql_sysconfig
if [ -z "$PLC_DB_PASSWORD" ] ; then
PLC_DB_PASSWORD=$(uuidgen)
plc-config --category=plc_db --variable=password --value="$PLC_DB_PASSWORD" --save=$local_config $local_config
if [ -z "$PLC_DB_PASSWORD" ] ; then
PLC_DB_PASSWORD=$(uuidgen)
plc-config --category=plc_db --variable=password --value="$PLC_DB_PASSWORD" --save=$local_config $local_config
fi
if ! psql -U $PLC_DB_USER -c "" template1 >/dev/null 2>&1 ; then
psql -U postgres -c "CREATE USER $PLC_DB_USER PASSWORD '$PLC_DB_PASSWORD'" template1
fi
if ! psql -U $PLC_DB_USER -c "" template1 >/dev/null 2>&1 ; then
psql -U postgres -c "CREATE USER $PLC_DB_USER PASSWORD '$PLC_DB_PASSWORD'" template1