<commit_before>#!/bin/sh
#
# install PostgreSQL and PostGIS
#
#======================================================================

. `dirname $0`/../lib_logging.sh  

info "Installing PosgreSQL RDBM ... "

#======================================================================

# STEP 1: INSTALL RPMS

yum --assumeyes install postgresql postgresql-server postgis python-psycopg2

# STEP 2: CONFIGURE THE STORAGE DIRECTORY 

if [ -n "$ODAOS_PGDATA_DIR" ]
then 
    info "Setting the PostgreSQL data location to: $ODAOS_PGDATA_DIR"
    echo "PGDATA=\"$ODAOS_PGDATA_DIR\"" > /etc/sysconfig/pgsql/postgresql
fi 

# STEP 3: INIT THE DB AND START THE SERVICE  

service postgresql initdb
chkconfig postgresql on
service postgresql start

# STEP 4: SETUP POSTGIS DATABASE TEMPLATE 

if [ -z "`sudo sudo -u postgres psql --list | grep template_postgis`" ] 
then 
    sudo -u postgres createdb template_postgis
    sudo -u postgres createlang plpgsql template_postgis

    PG_SHARE=/usr/share/pgsql

    POSTGIS_SQL="$PG_SHARE/contrib/postgis-64.sql"
    [ -f "$POSTGIS_SQL" ] || POSTGIS_SQL="$PG_SHARE/contrib/postgis.sql"

    sudo -u postgres psql -q -d template_postgis -f "$POSTGIS_SQL"
    sudo -u postgres psql -q -d template_postgis -f "$PG_SHARE/contrib/spatial_ref_sys.sql"
    sudo -u postgres psql -q -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
    sudo -u postgres psql -q -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
    sudo -u postgres psql -q -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
fi 
<commit_msg>Bugfix: PostgreSQL re-install.<commit_after>#!/bin/sh
#
# install PostgreSQL and PostGIS
#
#======================================================================

. `dirname $0`/../lib_logging.sh  

info "Installing PosgreSQL RDBM ... "

#======================================================================

# STEP 0: Shut-down the porgress if already installed and running.

if [ -f "/etc/init.d/postgresql" ]
then 
    service postgresql stop || :
    # remove existing DB cluster - all data will be lost
    [ ! -d "/var/lib/pgsql/data" ] || rm -fR "/var/lib/pgsql/data" 
    [ ! -d "$ODAOS_PGDATA_DIR" ] || rm -fR "$ODAOS_PGDATA_DIR" 
fi

# STEP 1: INSTALL RPMS

yum --assumeyes install postgresql postgresql-server postgis python-psycopg2

# STEP 2: CONFIGURE THE STORAGE DIRECTORY 

if [ -n "$ODAOS_PGDATA_DIR" ]
then 
    info "Setting the PostgreSQL data location to: $ODAOS_PGDATA_DIR"
    echo "PGDATA=\"$ODAOS_PGDATA_DIR\"" > /etc/sysconfig/pgsql/postgresql
fi 

# STEP 3: INIT THE DB AND START THE SERVICE  

service postgresql initdb
chkconfig postgresql on
service postgresql start

# STEP 4: SETUP POSTGIS DATABASE TEMPLATE 

if [ -z "`sudo sudo -u postgres psql --list | grep template_postgis`" ] 
then 
    sudo -u postgres createdb template_postgis
    sudo -u postgres createlang plpgsql template_postgis

    PG_SHARE=/usr/share/pgsql

    POSTGIS_SQL="$PG_SHARE/contrib/postgis-64.sql"
    [ -f "$POSTGIS_SQL" ] || POSTGIS_SQL="$PG_SHARE/contrib/postgis.sql"

    sudo -u postgres psql -q -d template_postgis -f "$POSTGIS_SQL"
    sudo -u postgres psql -q -d template_postgis -f "$PG_SHARE/contrib/spatial_ref_sys.sql"
    sudo -u postgres psql -q -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
    sudo -u postgres psql -q -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
    sudo -u postgres psql -q -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
fi 

{'fraction_non_alphanumeric': 0.1738759248719408, 'fraction_numerical': 0.004837791690381332, 'mean_word_length': 3.8684210526315788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6182231', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1218, 'n_words': 351}