#!/bin/bash

insert_initial_data() {
    printf "Inserting data  ...\n"
    execute_file "insert_data.sql" ${DATABASE} ${SERVERNAME} ${PORT} > /dev/null
    printf "Inserting pre-defined roles ...\n"
    execute_file "insert_predefined_roles.sql" ${DATABASE} ${SERVERNAME} ${PORT} > /dev/null
}

set_defaults() {
    ME=$(basename $0)
    SERVERNAME="localhost"
    PORT="5432"
    DATABASE="engine"
    USERNAME=""
    VERBOSE=false
    LOGFILE="$ME.log"
    export PGPASSFILE="/etc/ovirt-engine/.pgpass"
}

#refreshes views
refresh_views() {
    printf "Creating views...\n"
    execute_file "create_views.sql" ${DATABASE} ${SERVERNAME} ${PORT} > /dev/null
    execute_file "create_dwh_views.sql" ${DATABASE} ${SERVERNAME} ${PORT} > /dev/null
}


#!/bin/bash

insert_initial_data() {
    printf "Inserting data  ...\n"
    execute_file "insert_data.sql" ${DATABASE} ${SERVERNAME} ${PORT} > /dev/null
    printf "Inserting pre-defined roles ...\n"
    execute_file "insert_predefined_roles.sql" ${DATABASE} ${SERVERNAME} ${PORT} > /dev/null
}

set_defaults() {
    ME=$(basename $0)
    SERVERNAME="localhost"
    PORT="5432"
    DATABASE="engine"
    USERNAME=""
    VERBOSE=false
    LOGFILE="$ME.log"

    # When running in development environments the .pgpass file may not
    # exist or might not be readable, so we should try to use the file
    # stored in the home directory of the user instead:
    PGPASSFILE="/etc/ovirt-engine/.pgpass"
    if [ ! -r "${PGPASSFILE}" ]
    then
        PGPASSFILE="${HOME}/.pgpass"
    fi
    export PGPASSFILE
}

#refreshes views
refresh_views() {
    printf "Creating views...\n"
    execute_file "create_views.sql" ${DATABASE} ${SERVERNAME} ${PORT} > /dev/null
    execute_file "create_dwh_views.sql" ${DATABASE} ${SERVERNAME} ${PORT} > /dev/null
}


Use .pgpass from home in dev env
core: Use .pgpass from home in dev env

We use the .pgpass file from /etc/ovirt-engine in production
environments, but this doesn't exist or is not available in most
development environments, so we should try to use the file from user's
home directory. If we don't do that the create_db_devel.sh script keeps
asking for the database password for ever.

Change-Id: I87e36c169dcf3a0aa1914ed46ccea068231d6b6d
Signed-off-by: Juan Hernandez <59e5b8140de97cc91c3fb6c5342dce948469af8c@redhat.com>
