fi
# confirm database is present or create it
db_present=$( psql -U postgres -c "select * from pg_database;" -d template1 | grep $ZABBIX_DB_NAME )
if [ -z $db_present ] ; then
fi
# confirm database is present or create it
db_present=$( psql -U postgres -c "select * from pg_database;" -d template1 | grep $ZABBIX_DB_NAME )
if [ -z $db_present ] ; then
fi
# Create/update the unprivileged database user and password
if [ -z "$PLC_MONITOR_DBPASSWORD" ] ; then
fi
# Create/update the unprivileged database user and password
if [ -z "$PLC_MONITOR_DBPASSWORD" ] ; then
{
schema_present=$( psql -U $ZABBIX_DB_USER $ZABBIX_DB_NAME -c "\d;" < /dev/null | grep hosts )
if [ -z $schema_present ] ; then
{
schema_present=$( psql -U $ZABBIX_DB_USER $ZABBIX_DB_NAME -c "\d;" < /dev/null | grep hosts )
if [ -z $schema_present ] ; then
if_present_load "/usr/local/zabbix/misc/create/schema/postgresql.sql"
if_present_load "/usr/local/zabbix/misc/create/data/data.sql"
if_present_load "/usr/local/zabbix/misc/create/data/images_pgsql.sql"
if_present_load "/usr/local/zabbix/misc/create/schema/postgresql.sql"
if_present_load "/usr/local/zabbix/misc/create/data/data.sql"
if_present_load "/usr/local/zabbix/misc/create/data/images_pgsql.sql"
mkdir -p /var/lib/pgsql/data/pg_hba.conf.d
ZABCONF=/var/lib/pgsql/data/pg_hba.conf.d/zabbix.conf
if [ ! -f $ZABCONF ] ; then
mkdir -p /var/lib/pgsql/data/pg_hba.conf.d
ZABCONF=/var/lib/pgsql/data/pg_hba.conf.d/zabbix.conf
if [ ! -f $ZABCONF ] ; then
sed -e "s/#DBHost=.*/DBHost=$PLC_MONITOR_HOST/g" \
-e "s#DBName=.*#DBName=$ZABBIX_DB_NAME#g" \
-e "s#DBUser=.*#DBUser=$ZABBIX_DB_USER#g" \
sed -e "s/#DBHost=.*/DBHost=$PLC_MONITOR_HOST/g" \
-e "s#DBName=.*#DBName=$ZABBIX_DB_NAME#g" \
-e "s#DBUser=.*#DBUser=$ZABBIX_DB_USER#g" \