From c8fc47418dd2fe44733b436bd20f61aa86c1cf68 Mon Sep 17 00:00:00 2001
From: nruest <ruestn@gmail.com>
Date: Tue, 14 Jun 2016 09:36:36 -0400
Subject: [PATCH 1/3] First pass at #285; Update vagrant to use Drupal 8, and
 remove all Drupal 7 CRUFT.

---
 install/configs/add_default_fields.php |   5 -
 install/scripts/drupal.sh              | 122 +++++++++++++++----------
 install/scripts/post-install.sh        |   7 +-
 3 files changed, 77 insertions(+), 57 deletions(-)
 delete mode 100644 install/configs/add_default_fields.php

diff --git a/install/configs/add_default_fields.php b/install/configs/add_default_fields.php
deleted file mode 100644
index abce75fae..000000000
--- a/install/configs/add_default_fields.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-module_load_include('inc', 'islandora_dc', 'include/fields');
-islandora_dc_add_fields_to_bundle(ISLANDORA_COLLECTION_CONTENT_TYPE);
-islandora_dc_add_fields_to_bundle(ISLANDORA_BASIC_IMAGE_CONTENT_TYPE);
diff --git a/install/scripts/drupal.sh b/install/scripts/drupal.sh
index d255ba475..fbd9dc479 100755
--- a/install/scripts/drupal.sh
+++ b/install/scripts/drupal.sh
@@ -20,7 +20,7 @@ service apache2 reload
 cd /var/www/html
 
 # Download Drupal
-drush dl drupal-7 --drupal-project-rename=drupal
+drush dl drupal-8 --drupal-project-rename=drupal
 
 # Permissions
 chown -R www-data:www-data drupal
@@ -28,7 +28,7 @@ chmod -R g+w drupal
 
 # Do the install
 cd "$DRUPAL_HOME"
-drush si -y --db-url=mysql://root:islandora@localhost/drupal7 --site-name=Islandora-7.x-2.x
+drush si -y --db-url=mysql://root:islandora@localhost/drupal8 --site-name=Islandora-CLAW
 drush user-password admin --password=islandora
 
 # Set document root
@@ -48,66 +48,94 @@ rm /var/www/html/index.html
 # Cycle apache
 service apache2 restart
 
-# Make the modules and libraries directories
-if [ ! -d "$DRUPAL_HOME/sites/all/modules" ]; then
-  mkdir "$DRUPAL_HOME/sites/all/modules"
-fi
-
-if [ ! -d "$DRUPAL_HOME/sites/all/libraries" ]; then
-  mkdir "$DRUPAL_HOME/sites/all/libraries"
-fi
-
-cd "$DRUPAL_HOME/sites/all/modules"
+#Enable Core modules
+drush en -y responsive_image
+drush en -y syslog
+drush en -y serialization
+drush en -y basic_auth
+drush en -y rest
 
 # Islandora dependencies
-drush dl httprl
+## HAS NOT BEEN PORTED TO DRUPAL 8
+#drush dl httprl
+
+## Drupal 8 Alpha
 drush dl services
-drush dl field_permissions
-drush dl field_readonly
-drush dl views
-drush dl rdfx
+drush -y en services
+
+## Drupal 8 Alpha
+drush dl libraries
+drush -y en libraries
+
+## HAS NOT BEEN PORTED TO DRUPAL 8
+#drush dl field_permissions
+
+## HAS NOT BEEN PORTED TO DRUPAL 8
+#drush dl field_readonly
+
+## INCLUDED IN DRUPAL CORE
+#drush dl views
+
+## HAS NOT BEEN PORTED TO DRUPAL 8
+#drush dl rdfx
+
+## Drupal 8 Alpha
 drush dl entity
-drush dl uuid
-drush dl xml_field
-drush dl jquery_update
-git clone https://github.com/Islandora-Labs/xpath_field.git
+drush -y en entity
+
+## HAS NOT BEEN PORTED TO DRUPAL 8
+#drush dl uuid
+
+## HAS NOT BEEN PORTED TO DRUPAL 8
+#drush dl xml_field
+
+## INCLUDED IN DRUPAL CORE
+#drush dl jquery_update
+
+#git clone https://github.com/Islandora-Labs/xpath_field.git
+
+## Drupal 8 Beta
 drush dl hook_post_action
+drush -y en hook_post_action
 
-# Devel!
+# Devel
+## Drupal 8 Alpha
 drush dl devel
 drush -y en devel
 
 # Undocumented dependency for rdfx on ARC2 for RDF generation, and spyc.
-cd "$DRUPAL_HOME/sites/all/libraries"
-git clone https://github.com/mustangostang/spyc.git
-mkdir ARC2
-cd ARC2
-git clone https://github.com/semsol/arc2.git
-mv arc2 arc
-cd "$DRUPAL_HOME/sites/all/modules"
+#cd "$DRUPAL_HOME/sites/all/libraries"
+#git clone https://github.com/mustangostang/spyc.git
+#mkdir ARC2
+#cd ARC2
+#git clone https://github.com/semsol/arc2.git
+#mv arc2 arc
+#cd "$DRUPAL_HOME/sites/all/modules"
 
 # Apache Solr
-drush dl apachesolr
-drush en -y apachesolr
+## https://www.drupal.org/node/2613470
+#drush dl apachesolr
+#drush en -y apachesolr
+drush dl search_api
+drush en -y search_api
 
 # Copy new schema files and restart Tomcat
-cp -a "$DRUPAL_HOME"/sites/all/modules/apachesolr/solr-conf/solr-4.x/. "$SOLR_HOME"/collection1/conf/
-service tomcat7 restart
-
-cd "$DRUPAL_HOME/sites/all/modules"
-git clone https://github.com/Islandora-CLAW/islandora.git
-drush -y en islandora
-drush -y en islandora_dc
-drush -y en islandora_mods
-drush -y en islandora_basic_image
-drush -y en islandora_collection
-drush -y en islandora_apachesolr
-drush -y en islandora_delete_by_fedora_uri_service
-drush -y en islandora_medium_size_service
-drush -y en islandora_tn_service
+#cp -a "$DRUPAL_HOME"/sites/all/modules/apachesolr/solr-conf/solr-4.x/. "$SOLR_HOME"/collection1/conf/
+#service tomcat7 restart
+
+#cd "$DRUPAL_HOME/sites/all/modules"
+#git clone https://github.com/Islandora-CLAW/islandora.git
+#drush -y en islandora
+#drush -y en islandora_dc
+#drush -y en islandora_mods
+#drush -y en islandora_basic_image
+#drush -y en islandora_collection
+#drush -y en islandora_apachesolr
+#drush -y en islandora_delete_by_fedora_uri_service
+#drush -y en islandora_medium_size_service
+#drush -y en islandora_tn_service
 
 # Set default theme to bootstrap
-cd "$DRUPAL_HOME/sites/all/themes"
 drush -y dl bootstrap
 drush -y en bootstrap
-drush vset theme_default bootstrap
+drush -y config-set system.theme default bootstrap
diff --git a/install/scripts/post-install.sh b/install/scripts/post-install.sh
index 0915c2c66..91c468085 100644
--- a/install/scripts/post-install.sh
+++ b/install/scripts/post-install.sh
@@ -28,8 +28,5 @@ sleep 60
 $KARAF_CLIENT -f $KARAF_CONFIGS/watch.script
 
 # Fix ApacheSolr config
-drush -r "$DRUPAL_HOME" sqlq "update apachesolr_environment set url='http://localhost:8080/solr' where url='http://localhost:8983/solr'"
-drush -r "$DRUPAL_HOME" cc all
-
-# Add DC as some default fields for folks.
-drush -r "$DRUPAL_HOME" scr "$HOME_DIR"/islandora/install/configs/add_default_fields.php
+#drush -r "$DRUPAL_HOME" sqlq "update apachesolr_environment set url='http://localhost:8080/solr' where url='http://localhost:8983/solr'"
+#drush -r "$DRUPAL_HOME" cc all

From 2d28b1f864c7f3fef9306a96d6826318acdda60b Mon Sep 17 00:00:00 2001
From: nruest <ruestn@gmail.com>
Date: Sun, 19 Jun 2016 17:50:06 -0400
Subject: [PATCH 2/3] Code review

---
 install/Vagrantfile                |  3 ++-
 install/scripts/composer.sh        |  2 +-
 install/scripts/drupal.sh          |  7 +++++++
 install/scripts/twigcextensions.sh | 11 +++++++++++
 4 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100644 install/scripts/twigcextensions.sh

diff --git a/install/Vagrantfile b/install/Vagrantfile
index 557ea67c6..d23113deb 100644
--- a/install/Vagrantfile
+++ b/install/Vagrantfile
@@ -70,11 +70,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
   config.vm.provision :shell, :path => "./scripts/bootstrap.sh", :args => home_dir
   config.vm.provision :shell, :path => "./scripts/lamp-server.sh", :args => home_dir
   config.vm.provision :shell, :path => "./scripts/solr.sh", :args => home_dir
+  config.vm.provision :shell, :path => "./scripts/composer.sh", :args => home_dir
+  config.vm.provision :shell, :path => "./scripts/twigcextensions.sh", :args => home_dir
   config.vm.provision :shell, :path => "./scripts/drupal.sh", :args => home_dir
   config.vm.provision :shell, :path => "./scripts/fcrepo.sh", :args => home_dir
   config.vm.provision :shell, :path => "./scripts/blazegraph.sh", :args => home_dir
   config.vm.provision :shell, :path => "./scripts/alpaca.sh", :args => home_dir
-  config.vm.provision :shell, :path => "./scripts/composer.sh", :args => home_dir
   config.vm.provision :shell, :path => "./scripts/karaf.sh", :args => home_dir
   config.vm.provision :shell, :path => "./scripts/islandora-karaf-components.sh", :args => home_dir
   config.vm.provision :shell, :path => "./scripts/config.sh", :args => home_dir
diff --git a/install/scripts/composer.sh b/install/scripts/composer.sh
index 62505249d..02cb999bb 100644
--- a/install/scripts/composer.sh
+++ b/install/scripts/composer.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 echo "Installing Composer"
 
-apt-get install -y php5.6-mbstring
+apt-get install -y php5.6-mbstring php5.6-dev
 curl -sS https://getcomposer.org/installer | php
 php composer.phar install --no-progress
 mv composer.phar /usr/local/bin/composer
diff --git a/install/scripts/drupal.sh b/install/scripts/drupal.sh
index fbd9dc479..fd893bf0b 100755
--- a/install/scripts/drupal.sh
+++ b/install/scripts/drupal.sh
@@ -45,6 +45,12 @@ sed -i '$i</Directory>' /etc/apache2/apache2.conf
 # Torch the default index.html
 rm /var/www/html/index.html
 
+cat >> "$DRUPAL_HOME"/sites/default/settings.php <<EOF
+\$settings['trusted_host_patterns'] = array(
+'^localhost$',
+);
+EOF
+
 # Cycle apache
 service apache2 restart
 
@@ -117,6 +123,7 @@ drush -y en devel
 #drush dl apachesolr
 #drush en -y apachesolr
 drush dl search_api
+drush -y pm-uninstall search
 drush en -y search_api
 
 # Copy new schema files and restart Tomcat
diff --git a/install/scripts/twigcextensions.sh b/install/scripts/twigcextensions.sh
new file mode 100644
index 000000000..952323210
--- /dev/null
+++ b/install/scripts/twigcextensions.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+echo " Installing Twig C extentions"
+cd /home/vagrant
+composer require twig/twig:~1.0
+cd /home/vagrant/vendor/twig/twig/ext/twig
+phpize
+./configure
+make
+make install
+sed -i '$iextension=/usr/lib/php/20131226/twig.so' /etc/php/5.6/apache2/php.ini
+

From 64409c66065d90e9062095f112da72a5f02bed24 Mon Sep 17 00:00:00 2001
From: nruest <ruestn@gmail.com>
Date: Mon, 20 Jun 2016 09:08:13 -0400
Subject: [PATCH 3/3] Code review

---
 install/scripts/drupal.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/install/scripts/drupal.sh b/install/scripts/drupal.sh
index fd893bf0b..56d79c8ae 100755
--- a/install/scripts/drupal.sh
+++ b/install/scripts/drupal.sh
@@ -45,12 +45,17 @@ sed -i '$i</Directory>' /etc/apache2/apache2.conf
 # Torch the default index.html
 rm /var/www/html/index.html
 
+## Trusted Host Settings
 cat >> "$DRUPAL_HOME"/sites/default/settings.php <<EOF
 \$settings['trusted_host_patterns'] = array(
 '^localhost$',
 );
 EOF
 
+## The always_populate_raw_post_data PHP setting should be set to -1 in PHP version 5.6
+sed -i 's|#;always_populate_raw_post_data = -1|always_populate_raw_post_data = -1|g' /etc/php/5.6/apache2/php.ini
+sed -i 's|#;always_populate_raw_post_data = -1|always_populate_raw_post_data = -1|g' /etc/php/5.6/cli/php.ini
+
 # Cycle apache
 service apache2 restart