diff --git a/README.md b/README.md index 94d1bb6..dac53a7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Automatic Drupal and WissKi factory scripts +# Automatic Drupal and WissKI factory scripts This repository contains a factory server implementation that creates and maintains a list of Drupal Instances. @@ -39,7 +39,7 @@ In particular, these are: - serveral PHP modules that are dependencies of Drupal - [MariaDB](https://mariadb.org/) -- an SQL database - [Apache2](https://httpd.apache.org/), the corresponding php and [mpm-itk](http://mpm-itk.sesse.net/) modules -- a webserver -- [GraphDB](http://graphdb.ontotext.com/) - an SPARQL backend for WissKi +- [GraphDB](http://graphdb.ontotext.com/) - an SPARQL backend for WissKI With the exception of GraphDB all these components can be installed using Debian's package manager 'apt'. To install GraphDB, a zip with the binaries needs to be unpacked, and then a systemd service for it needs to be created. @@ -53,24 +53,24 @@ sudo bash /factory/system_install.sh /path/to/graphdb.zip In principle this script is idempotent, meaning it can be run multiple times achieving the same effect. -## Provisioning a new WissKi instance -- 'provision.sh' +## Provisioning a new WissKI instance -- 'provision.sh' *TLDR: `sudo bash provision.sh slug-of-new-website`* -A new WissKi instance consists of several components: +A new WissKI instance consists of several components: - A [Drupal](https://www.drupal.org/) instance, managed as a [Composer](https://getcomposer.org/) project - An [Apache](https://httpd.apache.org/) the makes the above available externally - An [SQL](https://mariadb.org/) database, to store Drupal Nodes in - A [GraphDB](https://graphdb.ontotext.com/) repository to store RDF triples in -Each WissKi instance is identified by a ``slug''. -This is a preferably short name that is used to form a domain name for the WissKi instance. +Each WissKI instance is identified by a ``slug''. +This is a preferably short name that is used to form a domain name for the WissKI instance. This factory assumes that each instance is a subdomain of a given domain. For example, if the given domain is 'wisskis.example.com' and the slug of a particular instance is 'blue', the subdomain used by this instance would be 'blue.wisskis.example.com'. The given domain can be configured within the '.env' file. -In this implementation we furthermore isolate each WissKi instance from the rest of the system. +In this implementation we furthermore isolate each WissKI instance from the rest of the system. For this purpose, we make use of an appropriate system user, an appropriate SQL user and a GraphDB user. **Note: GraphDB users are not yet implemented ** @@ -79,7 +79,7 @@ We thus use the following process to provision a new instance: __1. We create a new system user and hoem directory__ The username is derived from the slug, with a configurable prefix. -The home directory for this user will contain the Drupal PHP files needed to run a WissKi. +The home directory for this user will contain the Drupal PHP files needed to run a WissKI. For this reason, the home directory for each user is a subdirectory at a standardized location. By default this is `/var/www/factory/$USER', but this can be customized. @@ -101,13 +101,14 @@ The password for the 'admin' user is randomly generated in this process. __5. Create a GraphDB repository__ -Next, we create a dedidcated GraphDB repository for the WissKi instance. +Next, we create a dedidcated GraphDB repository for the WissKI instance. *TODO*: Create a GraphDB user. -__6. Add WissKi modules to Drupal__ +__6. Add WissKI modules to Drupal__ -Next, we add the required WissKi modules to Drupal. -*TODO*: Configure the WissKi modules automatically. +Next, we add the required WissKI modules to Drupal. +Also patch EasyRDF and make an ontology directory. +*TODO*: Configure the WissKI modules automatically. __7. Create a Apache VHost configuration__ @@ -122,11 +123,11 @@ To do so, use: sudo bash /factory/provision.sh SLUG ``` -## Manually editing WissKi instances -- 'shell.sh' +## Manually editing WissKI instances -- 'shell.sh' Sometimes it is needed to make manual adjustments to an individual instance. For this purpose, the `shell.sh` script exists. -It opens an interactive shell in the context of a given WissKi instance. +It opens an interactive shell in the context of a given WissKI instance. In particular it: - switches to the appropriate system user - sets up the '$PATH' environment variable to allow using 'drush' and 'composer' @@ -137,25 +138,25 @@ To use it, run: sudo bash /factory/shell.sh SLUG ``` -## Removing an existing WissKi instance -- 'remove.sh' +## Purge an existing WissKI instance -- 'purge.sh' * TODO: Document this more * -Sometimes it is required to remove a given WissKi instance. +Sometimes it is required to remove a given WissKI instance. In particular all parts belonging to it should be removed. To use it, run: ```bash -sudo bash /factory/remove.sh SLUG +sudo bash /factory/purge.sh SLUG ``` ## TODO -- Compare with Mark Fichtner approach +- Compare with Mark Fichtners approach - More documentation - Document and improve`update.sh` - User-level documentation @@ -164,10 +165,10 @@ sudo bash /factory/remove.sh SLUG - First steps after provisioning - Writeup approach to SSL (Wildcard cert with proxy that downgrades connections to plain http, or mod_md) - Automatically setup SALZ adapter (if this is possible) -- Setup users for GraphDB and enable security, is this supported by WissKi SALZ? -- Allow customization of GraphDB paths +- Setup users for GraphDB and enable security, is this supported by WissKI SALZ? +- Allow customization of GraphDB installation paths ## License -Licensed under GPL 3. \ No newline at end of file +Licensed under GPL 3. diff --git a/factory/.env.example b/factory/.env.example index a463763..6aab99d 100644 --- a/factory/.env.example +++ b/factory/.env.example @@ -1,4 +1,8 @@ -# All WissKi and Drupal Installations are contained within a single directory. +# Sometimes when http(s) is enabled, it is advisable to listen on a port different from 80. +# The public port can be configured here. +PUBLIC_PORT=80 + +# All WissKI and Drupal Installations are contained within a single directory. # The name of each subfolder corresponds to the appropriate domain name. # This variable determines the subfolder to place installations into. DRUPAL_ROOT=/var/www/factory diff --git a/factory/lib/10_config.sh b/factory/lib/10_config.sh index 49acaab..0e8236d 100644 --- a/factory/lib/10_config.sh +++ b/factory/lib/10_config.sh @@ -125,4 +125,11 @@ if ! is_valid_number "$PASSWORD_LENGTH"; then exit 1; fi +# The 'PUBLIC_PORT' must be a valid number. +if ! is_valid_number "$PUBLIC_PORT"; then + log_error "Variable 'PUBLIC_PORT' is missing or not a valid number. "; + log_info "Please verify that it is set correctly in '.env'. "; + exit 1; +fi + log_ok "Read and validated configuration file. " \ No newline at end of file diff --git a/factory/lib/20_slug.sh b/factory/lib/20_slug.sh index 9c60967..1ac1224 100644 --- a/factory/lib/20_slug.sh +++ b/factory/lib/20_slug.sh @@ -62,6 +62,7 @@ GRAPHDB_REPO="${GRAPHDB_REPO_PREFIX}${USERNAME_BASE}" BASE_DIR="$DRUPAL_ROOT/$INSTANCE_DOMAIN" COMPOSER_DIR="$BASE_DIR/project" WEB_DIR="$COMPOSER_DIR/web" +ONTOLOGY_DIR="$WEB_DIR/sites/default/files/ontology" # Setup aliases for drush and composer. alias composer="sudo -u $SYSTEM_USER /usr/local/bin/composer" diff --git a/factory/lib/30_templates.sh b/factory/lib/30_templates.sh new file mode 100644 index 0000000..60885e3 --- /dev/null +++ b/factory/lib/30_templates.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +# This is a library file. +# It should be 'source'd only, if it is not we bail out here. +if [[ "$0" = "$BASH_SOURCE" ]]; then + echo "This file should not be executed directly, it should be 'source'd only. " + exit 1; +fi + +TEMPLATE_DIR="$SCRIPT_DIR/resources/templates/" + +# load_template will load a template $1 from the template directory +# and replace ${$2} with $3, ${$4} with $5 etc. +# echoes out the replaced template +function load_template() { + # read the template then remove the argument + TEMPLATE=`cat "$TEMPLATE_DIR/$1"` + shift 1; + + # while we have a variable to substiute + while [ ! -z "$1" ] + do + # do the substitution + TEMPLATE="${TEMPLATE//\$\{$1\}/$2}" + shift 2 + done; + + # finally echo out the template + echo "$TEMPLATE" +} + +# path where common apache files will be installed. +WISSKI_COMMON_PATH="/etc/apache2/conf/wisski" \ No newline at end of file diff --git a/factory/lib/30_utils.sh b/factory/lib/40_utils.sh similarity index 100% rename from factory/lib/30_utils.sh rename to factory/lib/40_utils.sh diff --git a/factory/lib/lib.sh b/factory/lib/lib.sh index d0f1612..65074a5 100644 --- a/factory/lib/lib.sh +++ b/factory/lib/lib.sh @@ -17,4 +17,5 @@ LIB_DIR="$SCRIPT_DIR/lib" source "$LIB_DIR/00_init.sh"; source "$LIB_DIR/10_config.sh"; source "$LIB_DIR/20_slug.sh"; -source "$LIB_DIR/30_utils.sh"; +source "$LIB_DIR/30_templates.sh"; +source "$LIB_DIR/40_utils.sh"; diff --git a/factory/provision.sh b/factory/provision.sh index 2b841ee..b2d90a3 100644 --- a/factory/provision.sh +++ b/factory/provision.sh @@ -3,7 +3,7 @@ # This script will provision a new Drupal instance and make it available to apache. # Usage: sudo ./provision.sh $SLUG # In case the installation fails, it will bail out and leave you with an incomplete installation. -# To delete an incomplete installation, use the ./remove.sh script, or try fixing the error manually. +# To delete an incomplete installation, use the ./purge.sh script, or try fixing the error manually. set -e # read the lib/shared.sh and read the slug argument. @@ -13,6 +13,24 @@ source "$DIR/lib/lib.sh" require_slug_argument +# A global flag 'USE_DRUPAL_9' can be set to enable drupal 9 support. +# We print out the value of the flag here +if [ -z "${USE_DRUPAL_9}" ]; then + log_info " => Will install stable Drupal 8 (Use 'USE_DRUPAL_9=1' for Drupal 9). " +else + log_info " => Will install experimental Drupal 9 version ('USE_DRUPAL_9' was set)" +fi + +log_info " => Validing configuration" + +# If the base directory already exists, we might have accidentally picked a name that already exists. +# In that case we bail out for safety reasons. +if [ -d "$BASE_DIR" ]; then + echo "'$BASE_DIR' already exists. " + echo "Aborting provisioning, please make sure you picked a unique name. " + exit 1 +fi + # Check that the apache2 config is correct. # This is a sanity test so that we don't randomly fail later because of bad config. log_info " => Checking apache configuration" @@ -29,27 +47,23 @@ sudo -u "$SYSTEM_USER" mkdir -p "$COMPOSER_DIR" cd "$COMPOSER_DIR" # Write out a new apache configuration file into /etc/apache2/sites-available. -# We will need to substiute in some configuration directories. +# We will need to substitute in some configuration directories. log_info " => Writing new apache configuration file" -cat << EOF >> "$APACHE_CONFIG_SITE_AVAILABLE" - - DocumentRoot $WEB_DIR - ServerName $INSTANCE_DOMAIN - AssignUserId $SYSTEM_USER $SYSTEM_USER - - - Options Indexes FollowSymLinks - AllowOverride All - Require all granted - - ErrorLog \${APACHE_LOG_DIR}/error.log - CustomLog \${APACHE_LOG_DIR}/access.log combined - -EOF +load_template "wisski-site.conf" \ + "PUBLIC_PORT" "${PUBLIC_PORT}" \ + "WEB_DIR" "${WEB_DIR}" \ + "INSTANCE_DOMAIN" "${INSTANCE_DOMAIN}" \ + "SYSTEM_USER" "${SYSTEM_USER}" \ + "WISSKI_COMMON_PATH" "${WISSKI_COMMON_PATH}" \ + > "${APACHE_CONFIG_SITE_AVAILABLE}" # Create a new composer project. log_info " => Creating composer project" -composer create-project drupal/recommended-project . +if [ -z "${USE_DRUPAL_9}" ]; then + composer create-project 'drupal/recommended-project:^8.9.0' . +else + composer create-project 'drupal/recommended-project:^9.0.0' . +fi composer require drush/drush # Randomly generate the database name and user we will configure. @@ -73,90 +87,38 @@ DRUPAL_PASS="$(randompw)" # Use 'drush' to run the site-installation. # Here we need to use the username, password and database creds we made above. log_info " => Running drupal installation scripts" -drush site-install standard --yes --site-name=${INSTANCE_DOMAIN} --account-name=$DRUPAL_USER --account-pass=$DRUPAL_PASS --db-url=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@localhost/${MYSQL_DATABASE} +drush site-install standard --yes --site-name=${INSTANCE_DOMAIN} \ + --account-name=$DRUPAL_USER --account-pass=$DRUPAL_PASS \ + --db-url=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@localhost/${MYSQL_DATABASE} + drupal_sites_permission_workaround # Create a new repository for GraphDB. -# First write out the configuration into a new directory. -log_info " => Writing GraphDB configuration in temporary directory" -tmpdir="$(mktemp -d)" -cd "$tmpdir" -cat << EOF > repo-config.ttl -# Creates a new GraphDB repository with Wisski - -@prefix rdfs: . -@prefix rep: . -@prefix sr: . -@prefix sail: . -@prefix owlim: . - -[] a rep:Repository ; - rep:repositoryID "$GRAPHDB_REPO" ; - rdfs:label "$INSTANCE_DOMAIN" ; - rep:repositoryImpl [ - rep:repositoryType "graphdb:FreeSailRepository" ; - sr:sailImpl [ - sail:sailType "graphdb:FreeSail" ; - - owlim:owlim-license "" ; - - owlim:base-URL "http://$INSTANCE_DOMAIN/owlim#" ; - owlim:defaultNS "" ; - owlim:entity-index-size "10000000" ; - owlim:entity-id-size "32" ; - owlim:imports "" ; - owlim:repository-type "file-repository" ; - owlim:ruleset "empty" ; - owlim:storage-folder "storage" ; - - owlim:enable-context-index "false" ; - owlim:cache-memory "80m" ; - owlim:tuple-index-memory "80m" ; - - owlim:enablePredicateList "false" ; - owlim:predicate-memory "0%" ; - - owlim:fts-memory "0%" ; - owlim:ftsIndexPolicy "never" ; - owlim:ftsLiteralsOnly "true" ; - - owlim:in-memory-literal-properties "false" ; - owlim:enable-literal-index "true" ; - owlim:index-compression-ratio "-1" ; - - owlim:check-for-inconsistencies "false" ; - owlim:disable-sameAs "false" ; - owlim:enable-optimization "true" ; - owlim:transaction-mode "safe" ; - owlim:transaction-isolation "true" ; - owlim:query-timeout "0" ; - owlim:query-limit-results "0" ; - owlim:throw-QueryEvaluationException-on-timeout "false" ; - owlim:useShutdownHooks "true" ; - owlim:read-only "false" ; - owlim:nonInterpretablePredicates "http://www.w3.org/2000/01/rdf-schema#label;http://www.w3.org/1999/02/22-rdf-syntax-ns#type;http://www.ontotext.com/owlim/ces#gazetteerConfig;http://www.ontotext.com/owlim/ces#metadataConfig" ; - ] - ]. -EOF - -# Create the configuration and use the configuration generated above. +# Use the template for this. # TODO: Permissions for GraphdDB -log_info "Generating new GraphDB repository '$GRAPHDB_REPO'" -curl -X POST\ - http://127.0.0.1:7200/rest/repositories\ - -H 'Content-Type: multipart/form-data'\ - -F "config=@repo-config.ttl" +log_info " => Generating new GraphDB repository '$GRAPHDB_REPO'" +load_template "graphdb-repo.ttl" "GRAPHDB_REPO" "${GRAPHDB_REPO}" "INSTANCE_DOMAIN" "${INSTANCE_DOMAIN}" | \ +curl -X POST \ + http://127.0.0.1:7200/rest/repositories \ + -H 'Content-Type: multipart/form-data' \ + -F "config=@-" -# Remove the temporary directory. -cd .. -rm -rf "$tmpdir" +# create a directory for ontologies. +log_info " => Creating '$ONTOLOGY_DIR'" +mkdir -p "$ONTOLOGY_DIR" # Install the Wisski packages. log_info " => Installing Wisski packages" cd "$COMPOSER_DIR" drupal_sites_permission_workaround -composer require drupal/wisski + +# install the development version when requested +if [ -z "${USE_DRUPAL_9}" ]; then + composer require 'drupal/wisski' +else + composer require 'drupal/wisski:2.x-dev' +fi drupal_sites_permission_workaround composer require drupal/inline_entity_form @@ -170,13 +132,35 @@ composer require drupal/image_effects drupal_sites_permission_workaround composer require drupal/colorbox +log_info " => Installation is now technically complete. " +log_ok "Some things below may fail. If that is the case, run: " +log_ok "$ a2ensite \"${INSTANCE_DOMAIN}\"" +log_ok "$ systemctl reload apache2" +log_ok "$ $SCRIPT_DIR/shell.sh $SLUG" +log_ok "Your installation details are as follows" +function printdetails() { + echo "URL: http://$INSTANCE_DOMAIN" + echo "Username: $DRUPAL_USER" + echo "Password: $DRUPAL_PASS" + log_info " => Your GraphDB details (for WissKI Salz) are: " + echo "Read URL: http://127.0.0.1:7200/repositories/$GRAPHDB_REPO" + echo "Write URL: http://127.0.0.1:7200/repositories/$GRAPHDB_REPO/statements" + echo "Writable: yes" + echo "Default Graph URI: http://$INSTANCE_DOMAIN/#" + echo "Ontology Paths: (empty)" + echo "SameAs property: http://www.w3.org/2002/07/owl#sameAs" +} +printdetails -# Enable the WissKi modules. +# Enable the WissKI modules. log_info " => Enable Wisski modules" drush pm-enable --yes wisski_core wisski_linkblock wisski_pathbuilder wisski_adapter_sparql11_pb wisski_salz drupal_sites_permission_workaround -# TODO: Setup WissKi-Salz. +# Because of a regresssion in EasyRDF and Tomcat, we need to manually patch EasyRDF +EASYRDF_RESPONSE="$COMPOSER_DIR/vendor/easyrdf/easyrdf/lib/EasyRdf/Http/Response.php" +log_info " => Patching '$EASYRDF_RESPONSE'" +load_template "easyrdf.patch" | patch "$EASYRDF_RESPONSE" # Finally enable the apache2 config. # And then reload to start serving it. @@ -184,17 +168,6 @@ log_info " => Enabling and reloading apache configuration" a2ensite "${INSTANCE_DOMAIN}" systemctl reload apache2 -# TODO: Certbot support - # and done! log_info " => Finished, your Drupal details are: " -echo "URL: http://$INSTANCE_DOMAIN" -echo "Username: $DRUPAL_USER" -echo "Password: $DRUPAL_PASS" -log_info " => Your GraphDB details (for WissKi Salz) are: " -echo "Read URL: http://127.0.0.1:7200/repositories/$GRAPHDB_REPO" -echo "Write URL: http://127.0.0.1:7200/repositories/$GRAPHDB_REPO/statements" -echo "Writable: yes" -echo "Default Graph URI: http://$INSTANCE_DOMAIN/owlim#" -echo "Ontology Paths: (empty)" -echo "SameAs property: http://www.w3.org/2002/07/owl#sameAs" \ No newline at end of file +printdetails diff --git a/factory/remove.sh b/factory/purge.sh similarity index 89% rename from factory/remove.sh rename to factory/purge.sh index 2b8dd22..9edd677 100644 --- a/factory/remove.sh +++ b/factory/purge.sh @@ -9,7 +9,7 @@ cd "$DIR" source "$DIR/lib/lib.sh" require_slug_argument -# Delete the apache configurationf files first. +# Delete the apache configuration files first. # This prevents drupal from being served. log_info " => Removing apache configuration files" rm "$APACHE_CONFIG_SITE_ENABLED" || true @@ -23,6 +23,7 @@ systemctl reload apache2 log_info " => Deleting MySQL database '$MYSQL_DATABASE' and user '$MYSQL_USER'. " mysql -e "DROP DATABASE IF EXISTS \`${MYSQL_DATABASE}\`;" || true mysql -e "DROP USER IF EXISTS \`${MYSQL_USER}\`@localhost;" || true +mysql -e "FLUSH PRIVILEGES;" # Clear the GraphDB repository. log_info " => Deleting GraphDB repository '$GRAPHDB_REPO'" @@ -36,4 +37,4 @@ delgroup "$SYSTEM_USER" || true log_info " => Removing directory '$BASE_DIR'" rm -rf "$BASE_DIR" -log_info " => Finished, '$INSTANCE_DOMAIN' has been removed. " \ No newline at end of file +log_info " => Finished, '$INSTANCE_DOMAIN' has been purged. " \ No newline at end of file diff --git a/factory/resources/templates/easyrdf.patch b/factory/resources/templates/easyrdf.patch new file mode 100644 index 0000000..46daa01 --- /dev/null +++ b/factory/resources/templates/easyrdf.patch @@ -0,0 +1,4 @@ +281c281 +< if (preg_match("|^HTTP/([\d\.x]+) (\d+) ([^\r\n]+)|", $status, $m)) { +--- +> if(preg_match("|^HTTP/([\d\.x]+) (\d+) ([^\r\n]*)|", $status, $m)) { diff --git a/factory/resources/templates/graphdb-repo.ttl b/factory/resources/templates/graphdb-repo.ttl new file mode 100644 index 0000000..86b78ae --- /dev/null +++ b/factory/resources/templates/graphdb-repo.ttl @@ -0,0 +1,57 @@ +# This file is used to initialize a new GraphDB repository. +# In this file the variables ${GRAPHDB_REPO} and ${INSTANCE_DOMAIN} will be replaced. +# All other variables will be left untouched. + +@prefix rdfs: . +@prefix rep: . +@prefix sr: . +@prefix sail: . +@prefix owlim: . + +[] a rep:Repository ; + rep:repositoryID "${GRAPHDB_REPO}" ; + rdfs:label "${INSTANCE_DOMAIN}" ; + rep:repositoryImpl [ + rep:repositoryType "graphdb:FreeSailRepository" ; + sr:sailImpl [ + sail:sailType "graphdb:FreeSail" ; + + owlim:owlim-license "" ; + + owlim:base-URL "http://${INSTANCE_DOMAIN}/#" ; + owlim:defaultNS "" ; + owlim:entity-index-size "10000000" ; + owlim:entity-id-size "32" ; + owlim:imports "" ; + owlim:repository-type "file-repository" ; + owlim:ruleset "empty" ; + owlim:storage-folder "storage" ; + + owlim:enable-context-index "false" ; + owlim:cache-memory "80m" ; + owlim:tuple-index-memory "80m" ; + + owlim:enablePredicateList "false" ; + owlim:predicate-memory "0%" ; + + owlim:fts-memory "0%" ; + owlim:ftsIndexPolicy "never" ; + owlim:ftsLiteralsOnly "true" ; + + owlim:in-memory-literal-properties "false" ; + owlim:enable-literal-index "true" ; + owlim:index-compression-ratio "-1" ; + + owlim:check-for-inconsistencies "false" ; + owlim:disable-sameAs "false" ; + owlim:enable-optimization "true" ; + owlim:transaction-mode "safe" ; + owlim:transaction-isolation "true" ; + owlim:query-timeout "0" ; + owlim:query-limit-results "0" ; + owlim:throw-QueryEvaluationException-on-timeout "false" ; + owlim:useShutdownHooks "true" ; + owlim:read-only "false" ; + owlim:nonInterpretablePredicates "http://www.w3.org/2000/01/rdf-schema#label;http://www.w3.org/1999/02/22-rdf-syntax-ns#type;http://www.ontotext.com/owlim/ces#gazetteerConfig;http://www.ontotext.com/owlim/ces#metadataConfig" ; + ] + ]. \ No newline at end of file diff --git a/factory/resources/templates/graphdb.service b/factory/resources/templates/graphdb.service new file mode 100644 index 0000000..9e77c83 --- /dev/null +++ b/factory/resources/templates/graphdb.service @@ -0,0 +1,17 @@ +# This file contains a systemd service for GraphDB. +# It was tailed to a WissKI service and may or may not work in general. + +[Unit] +Description=GraphDB + +[Service] +Type=simple +# use the special graphdb user and group, so that other users can not just access this system. +User=graphdb +Group=graphdb + +# The options here make it listen only on 127.0.0.1; this prevents external users from attempting access. +ExecStart=/opt/graphdb/bin/graphdb –Xmx6g -Dgraphdb.connector.address=127.0.0.1 + +[Install] +WantedBy=multi-user.target diff --git a/factory/resources/templates/wisski-site.conf b/factory/resources/templates/wisski-site.conf new file mode 100644 index 0000000..471bad6 --- /dev/null +++ b/factory/resources/templates/wisski-site.conf @@ -0,0 +1,16 @@ +# This file was generated automatically. +# It contains configuration for the WissKI site: +# ${INSTANCE_DOMAIN} +# Do not edit unless you know exactly what you are doing. + + + DocumentRoot ${WEB_DIR} + ServerName ${INSTANCE_DOMAIN} + AssignUserId ${SYSTEM_USER} ${SYSTEM_USER} + + + include "${WISSKI_COMMON_PATH}/wisski-common-dir.conf" + + + include "${WISSKI_COMMON_PATH}/wisski-common.conf" + \ No newline at end of file diff --git a/factory/resources/wisski-apache-common/wisski-common-dir.conf b/factory/resources/wisski-apache-common/wisski-common-dir.conf new file mode 100644 index 0000000..fa577ea --- /dev/null +++ b/factory/resources/wisski-apache-common/wisski-common-dir.conf @@ -0,0 +1,14 @@ +# This file is included inside the 'directory' configuration of all WissKI sites. + +# add types for .owl and .rdf +AddType application/rdf+xml .owl +AddType application/rdf+xml .rdf + +# Rewrites the ontology directory +ReWriteRule ^(ontology/[^/]+/).+ $1 [R=303,L] +ReWriteRule ^(ontology/[^/]+)/$ sites/default/files/$1.owl [L] + +# Allow overrides of symlinks +Options Indexes FollowSymLinks +AllowOverride All +Require all granted diff --git a/factory/resources/wisski-apache-common/wisski-common.conf b/factory/resources/wisski-apache-common/wisski-common.conf new file mode 100644 index 0000000..cde5e2c --- /dev/null +++ b/factory/resources/wisski-apache-common/wisski-common.conf @@ -0,0 +1,4 @@ +# This file is included inside the 'virtualhost' of a WissKI site. + +ErrorLog ${APACHE_LOG_DIR}/error.log +CustomLog ${APACHE_LOG_DIR}/access.log combined diff --git a/factory/system_install.sh b/factory/system_install.sh index 670d679..c299ff1 100755 --- a/factory/system_install.sh +++ b/factory/system_install.sh @@ -35,7 +35,7 @@ apt-get install -y curl php-cli php-mbstring git unzip curl -sS https://getcomposer.org/installer -o "$tmpdir/composer-setup.php" php $tmpdir/composer-setup.php --install-dir=/usr/local/bin --filename=composer -# Install required php extensions for Drupal and WissKi. +# Install required php extensions for Drupal and WissKI. log_info " => Installing required php extensions" apt-get install -y php-xml php-gd php-mysql php-common php-xmlrpc php-soap php-gd php-intl php-mysql php-zip php-curl php-ssh2 @@ -47,6 +47,15 @@ apt-get -y install mariadb-server log_info " => Installing apache2, php and auth modules" apt-get install -y apache2 libapache2-mod-php libapache2-mpm-itk +# Install apache and required php extensions. +log_info " => Enabling apache 'rewrite' module" +a2enmod rewrite + +# Copy over the wisski templates +log_info " => Copying over Apache Templates" +mkdir -p "$WISSKI_COMMON_PATH" +cp -v $SCRIPT_DIR/resources/wisski-apache-common/* "$WISSKI_COMMON_PATH" + # Make the directory for all drupal instances to live in. log_info " => Making root directory for Drupal Installations" mkdir -p "$DRUPAL_ROOT" @@ -85,19 +94,7 @@ chown -R graphdb:graphdb /opt/graphdb # This file uses the users created above, and also hard-codes listening address and maximum memory. # This avoids having to write the config file using bash hacks. log_info " => Making 'graphdb.service'" -cat << "EOF" > /etc/systemd/system/graphdb.service -[Unit] -Description=GraphDB - -[Service] -Type=simple -User=graphdb -Group=graphdb -ExecStart=/opt/graphdb/bin/graphdb –Xmx6g -Dgraphdb.connector.address=127.0.0.1 - -[Install] -WantedBy=multi-user.target -EOF +load_template 'graphdb.service' > /etc/systemd/system/graphdb.service # We just created a service, so now start it and put it into autostart mode. log_info " => Starting and enabling graphdb.service"