<commit_before>System Setup
====================================

# Instructions for RHEL 7/Scientific Linux 7

# install OS dependancies
yum install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
yum install http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-1.noarch.rpm
sudo yum -y groupinstall "PostgreSQL Database Server 9.4 PGDG"
sudo yum -y install git httpd ant tomcat-webapps postgresql-jdbc perl-DBD-Pg perl-Digest-SHA perl-CGI postgis2_94 postgis2_94-client postgis2_94-utils ImageMagick pgbouncer

# initialize postgres database
sudo /usr/pgsql-9.4/bin/postgresql94-setup initdb

# Enable postgres user/password auth
sudo vi /var/lib/pgsql/9.4/data/pg_hba.conf

# change line:
host    all         all         127.0.0.1/32          ident
# To:
host    all         all         127.0.0.1/32          trust

# ensure postgres starts on boot
sudo systemctl enable postgresql-9.4.service
sudo systemctl enable tomcat.service
sudo systemctl enable httpd.service
sudo systemctl enable pgbouncer.service

# start postgres
sudo systemctl restart postgresql-9.4.service

# set a password for postgres user
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '<PASSWORD>';" postgres

# if using SELinux, run the following commands
# note: httpd_use_nfs=true because satellite imagery is on NFS mount
sudo setsebool -P httpd_builtin_scripting=true httpd_can_network_connect=true httpd_can_network_connect_db=true httpd_can_sendmail=true httpd_enable_cgi=true httpd_use_nfs=true


Create a picturepost instance
====================================
cd /opt

# If you are an UNH RCC employee run this command
git clone <EMAIL>:picturepost

# OR
# If are external to UNH RCC run this command
# If this command gives you trouble, itis likely that you
# need to send us your public ssh key to <EMAIL>
git clone <EMAIL>

# set up new tomcat virtual host
vi /usr/share/tomcat/conf/server.xml 
  <Host name="picturepost.sr.unh.edu" appBase="/opt/picturepost/webapps">
    <Context docBase="ROOT" path="" allowLinking="true">
      <Parameter name="BASE_PATH" value="/opt/picturepost" />
    </Context>
  </Host>

  <!-- verify Connector has a large maxPostSize (otherwise large photo uploads won't work)
  <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" maxPostSize="20971520" />


# go into project directory
cd /opt/picturepost

# execute setup and follow instructions to create a config file
# ignore error regarding failed database connection
sudo bin/picpost setup

# set up new apache virtual host
cd /etc/httpd/conf.d
ln -s /opt/picturepost/conf/apache/apache.conf picturepost.conf

# You will need to install data and a database
# If you want to develop on a fresh database with no data, use the starter database
cd /opt/picturepost
cp src/starter_database.sql.gz data/backup.sql.gz
bin/picpost restore

# OR if you want a copy of the live data (you need ~ 80G free space)
rsync -av picturepost.unh.edu:/opt/picturepost/data data/

# run command to restore database from data/backup.sql.gz
bin/picpost restore

# configure bgbouncer connection pooling
cd /etc/pgbouncer
vi pgbouncer.ini

# add connection
picturepost = host=127.0.0.1 port=5432 user=dbuser client_encoding=UNICODE datestyle=ISO connect_query='SELECT 1'

# uncomment this line
ignore_startup_parameters = extra_float_digits

# save file

# add userlist file
python mkauth.py userlist.txt "host=127.0.0.1 dbname=postgres user=postgres"
chown pgbouncer userlist.txt

# restart the services
sudo systemctl restart pgbouncer.service

# test bgbouncer connection
psql -h 127.0.0.1 -p 6432 -U dbuser picturepost

# run setup again to complete the setup process
# this will also build java files, restart tomcat, restart apache
/opt/picturepost/bin/picpost setup





Build colorMod
======================================
cd /tmp
git clone https://github.com/collinsp/colorMod.git 
cd colorMod
make
cp colorMod /opt/picturepost/bin


Configure Crontabs (ignore on dev systems)
======================================
sudo su
crontab -e<commit_msg>A few minor fixes to the install script<commit_after>System Setup
====================================

# Instructions for RHEL 7/Scientific Linux 7

# install OS dependancies
yum install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpm #mdl changed from 7.5 to 7.6 2015/05/10
yum install http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-1.noarch.rpm
sudo yum -y groupinstall "PostgreSQL Database Server 9.4 PGDG"
sudo yum -y install git httpd ant tomcat-webapps postgresql-jdbc perl-DBD-Pg perl-Digest-SHA perl-CGI postgis2_94 postgis2_94-client postgis2_94-utils ImageMagick pgbouncer

# initialize postgres database
sudo /usr/pgsql-9.4/bin/postgresql94-setup initdb

# Enable postgres user/password auth
sudo vi /var/lib/pgsql/9.4/data/pg_hba.conf

# change line:
host    all         all         127.0.0.1/32          ident
# To:
host    all         all         127.0.0.1/32          trust

# ensure postgres starts on boot
sudo systemctl enable postgresql-9.4.service
sudo systemctl enable tomcat.service
sudo systemctl enable httpd.service
sudo systemctl enable pgbouncer.service

# start postgres
sudo systemctl restart postgresql-9.4.service

# set a password for postgres user
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '<PASSWORD>';" postgres

# if using SELinux, run the following commands
# note: httpd_use_nfs=true because satellite imagery is on NFS mount
sudo setsebool -P httpd_builtin_scripting=true httpd_can_network_connect=true httpd_can_network_connect_db=true httpd_can_sendmail=true httpd_enable_cgi=true httpd_use_nfs=true


Create a picturepost instance
====================================
cd /opt

# If you are an UNH RCC employee run this command
git clone <EMAIL>:picturepost

# OR
# If are external to UNH RCC run this command
# If this command gives you trouble, itis likely that you
# need to send us your public ssh key to <EMAIL>
git clone <EMAIL>

# set up new tomcat virtual host
vi /usr/share/tomcat/conf/server.xml 
  <Host name="picturepost.sr.unh.edu" appBase="/opt/picturepost/webapps">
    <Context docBase="ROOT" path="" allowLinking="true">
      <Parameter name="BASE_PATH" value="/opt/picturepost" />
    </Context>
  </Host>

  <!-- verify Connector has a large maxPostSize (otherwise large photo uploads won't work)
  <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" maxPostSize="20971520" />


# go into project directory
cd /opt/picturepost

# execute setup and follow instructions to create a config file
# ignore error regarding failed database connection
sudo bin/picpost setup

# set up new apache virtual host
cd /etc/httpd/conf.d
ln -s /opt/picturepost/conf/apache/apache.conf picturepost.conf

# You will need to install data and a database
# If you want to develop on a fresh database with no data, use the starter database
cd /opt/picturepost
cp src/starter_database.sql.gz data/backup.sql.gz
bin/picpost restore

# OR if you want a copy of the live data (you need ~ 80G free space)
rsync -av picturepost.unh.edu:/opt/picturepost/data data/

# run command to restore database from data/backup.sql.gz
bin/picpost restore

# configure bgbouncer connection pooling
cd /etc/pgbouncer
vi pgbouncer.ini

# add connection
picturepost = host=127.0.0.1 port=5432 user=dbuser client_encoding=UNICODE datestyle=ISO connect_query='SELECT 1'

# uncomment this line
ignore_startup_parameters = extra_float_digits

# save file


# MDL added following so that mkauth.py can be run
# sudo yum install python-psycopg2

# add userlist file
python mkauth.py userlist.txt "host=127.0.0.1 dbname=postgres user=postgres"
chown pgbouncer userlist.txt

# restart the services
sudo systemctl restart pgbouncer.service

# test pgbouncer connection
psql -h 127.0.0.1 -p 6432 -U dbuser picturepost

# run setup again to complete the setup process
# this will also build java files, restart tomcat, restart apache
/opt/picturepost/bin/picpost setup





Build colorMod
======================================
cd /tmp
git clone https://github.com/collinsp/colorMod.git 
cd colorMod
make
cp colorMod /opt/picturepost/bin


Configure Crontabs (ignore on dev systems)
======================================
sudo su
crontab -e
{'fraction_non_alphanumeric': 0.11270491803278689, 'fraction_numerical': 0.02688042430086789, 'mean_word_length': 4.352903225806451, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 10, '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': '4576305', 'n_tokens_mistral': 2826, 'n_tokens_neox': 2636, 'n_words': 872}