Skip to content

Commit

Permalink
installation: CentOS7 instruction fixes
Browse files Browse the repository at this point in the history
* BETTER Improves NodeJS installation instructions for CentOS7 by
  switching to using upstream NodeJS procedures instead of EPEL. This
  permits to update NPM just like for Ubuntu.

* BETTER Adds more SELinux-oriented installation commands that are
  necessary for CentOS7 boxes that use SELinux.

* FIX Fixes firewall installation instructions for CentOS7.

* FIX Amends upgrading of virtualenvwrapper fixing Ubuntu14 installation
  issue.

* Switches to `centos/7` Vagrant base image.

* Removes provisioning of `uuid` package on CentOS7 that is no longer
  necessary.

* Alters order of "create instance", "populate instance" and "start
  instance" commands for Vagrant based installation technique.

* Note that the three installation techniques (Docker, Ubuntu14 via
  Vagrant, CentOS7 via Vagrant) are all successfully passing at the time
  of this commit.

Signed-off-by: Tibor Simko <tibor.simko@cern.ch>
  • Loading branch information
tiborsimko committed Mar 9, 2017
1 parent d056e43 commit 5dc654e
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 53 deletions.
31 changes: 15 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2015, 2016 CERN.
# Copyright (C) 2015, 2016, 2017 CERN.
#
# Invenio is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
Expand All @@ -25,21 +25,6 @@
# Use Python-2.7:
FROM python:2.7-slim

COPY scripts/provision-web.sh /tmp/

# Install Invenio web node pre-requisites:
RUN /tmp/provision-web.sh

# Add Invenio sources to `code` and work there:
WORKDIR /code
ADD . /code

# Run container as user `invenio` with UID `1000`, which should match
# current host user in most situations:
RUN adduser --uid 1000 --disabled-password --gecos '' invenio && \
chown -R invenio:invenio /code
USER invenio

# Configure Invenio instance:
ENV INVENIO_WEB_HOST=127.0.0.1
ENV INVENIO_WEB_INSTANCE=invenio3
Expand All @@ -55,6 +40,20 @@ ENV INVENIO_ELASTICSEARCH_HOST=elasticsearch
ENV INVENIO_RABBITMQ_HOST=rabbitmq
ENV INVENIO_WORKER_HOST=127.0.0.1

# Install Invenio web node pre-requisites:
COPY scripts/provision-web.sh /tmp/
RUN /tmp/provision-web.sh

# Add Invenio sources to `code` and work there:
WORKDIR /code
ADD . /code

# Run container as user `invenio` with UID `1000`, which should match
# current host user in most situations:
RUN adduser --uid 1000 --disabled-password --gecos '' invenio && \
chown -R invenio:invenio /code
USER invenio

# Create Invenio instance:
RUN /code/scripts/create-instance.sh

Expand Down
6 changes: 3 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2015, 2016 CERN.
# Copyright (C) 2015, 2016, 2017 CERN.
#
# Invenio is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -33,11 +33,11 @@
#
# $ vagrant up
# $ vagrant ssh web -c 'source .inveniorc && /vagrant/scripts/create-instance.sh'
# $ vagrant ssh web -c 'source .inveniorc && nohup /vagrant/scripts/start-instance.sh'
# $ vagrant ssh web -c 'source .inveniorc && /vagrant/scripts/populate-instance.sh'
# $ vagrant ssh web -c 'source .inveniorc && nohup /vagrant/scripts/start-instance.sh'
# $ firefox http://192.168.50.10/records/1

#OS = 'hfm4/centos7'
#OS = 'centos/7'
OS = 'ubuntu/trusty64'

Vagrant.configure("2") do |config|
Expand Down
38 changes: 19 additions & 19 deletions docs/installation/installation-detailed.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. This file is part of Invenio
Copyright (C) 2014, 2015, 2016 CERN.
Copyright (C) 2014, 2015, 2016, 2017 CERN.
Invenio is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -521,8 +521,8 @@ following scripts:
source .inveniorc
./scripts/create-instance.sh
./scripts/start-instance.sh
./scripts/populate-instance.sh
./scripts/start-instance.sh
.. note::

Expand Down Expand Up @@ -595,23 +595,6 @@ We can now collect and build CSS/JS assets of our Invenio instance:
Our first new Invenio instance is created and ready for loading some example
records.

Start instance
~~~~~~~~~~~~~~

Let's now start the web application:

.. include:: ../../scripts/start-instance.sh
:start-after: # sphinxdoc-start-application-begin
:end-before: # sphinxdoc-start-application-end
:literal:

and the web server:

.. include:: ../../scripts/start-instance.sh
:start-after: # sphinxdoc-start-nginx-begin
:end-before: # sphinxdoc-start-nginx-end
:literal:

Populate instance
~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -646,6 +629,23 @@ Let's index all the uploaded records:
:end-before: # sphinxdoc-index-all-records-end
:literal:

Start instance
~~~~~~~~~~~~~~

Let's now start the web application:

.. include:: ../../scripts/start-instance.sh
:start-after: # sphinxdoc-start-application-begin
:end-before: # sphinxdoc-start-application-end
:literal:

and the web server:

.. include:: ../../scripts/start-instance.sh
:start-after: # sphinxdoc-start-nginx-begin
:end-before: # sphinxdoc-start-nginx-end
:literal:

We should now see our demo records on the web:

.. code-block:: shell
Expand Down
4 changes: 2 additions & 2 deletions docs/installation/installation-quick.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. This file is part of Invenio
Copyright (C) 2014, 2015, 2016 CERN.
Copyright (C) 2014, 2015, 2016, 2017 CERN.
Invenio is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -35,8 +35,8 @@ You can get Invenio v3.0 demo site up and running using Vagrant::

vagrant up
vagrant ssh web -c 'source .inveniorc && /vagrant/scripts/create-instance.sh'
vagrant ssh web -c 'source .inveniorc && nohup /vagrant/scripts/start-instance.sh'
vagrant ssh web -c 'source .inveniorc && /vagrant/scripts/populate-instance.sh'
vagrant ssh web -c 'source .inveniorc && nohup /vagrant/scripts/start-instance.sh'
firefox http://192.168.50.10/records/1

Using kickstart scripts
Expand Down
46 changes: 33 additions & 13 deletions scripts/provision-web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
# quit on errors:
set -o errexit

# check environment variables:
if [ "${INVENIO_WEB_VENV}" = "" ]; then
echo "[ERROR] Please set environment variable INVENIO_WEB_VENV before runnning this script."
echo "[ERROR] Example: export INVENIO_WEB_VENV=invenio3"
exit 1
fi

# quit on unbound symbols:
set -o nounset

Expand Down Expand Up @@ -101,14 +108,12 @@ provision_web_common_centos7 () {
rlwrap \
screen \
vim

# install uuid generator (useful for loading demo records):
$sudo yum install -y \
uuid
# sphinxdoc-install-useful-system-tools-centos7-end

# sphinxdoc-add-nodejs-external-repository-centos7-begin
# nothing needed; EPEL added already
if [[ ! -f /etc/yum.repos.d/nodesource-el.repo ]]; then
curl -sL https://rpm.nodesource.com/setup_4.x | $sudo bash -
fi
# sphinxdoc-add-nodejs-external-repository-centos7-end

# sphinxdoc-install-web-common-centos7-begin
Expand All @@ -119,9 +124,12 @@ provision_web_common_centos7 () {
libffi-devel \
libxml2-devel \
libxslt-devel \
npm \
openssl-devel \
policycoreutils-python \
python-devel \
python-pip
$sudo yum install -y --disablerepo=epel \
nodejs
# sphinxdoc-install-web-common-centos7-end

}
Expand All @@ -137,7 +145,7 @@ provision_web_libpostgresql_centos7 () {
setup_npm_and_css_js_filters () {

# sphinxdoc-install-npm-and-css-js-filters-begin
$sudo su -c "npm install -g npm"
# $sudo su -c "npm install -g npm"
$sudo su -c "npm install -g node-sass@3.8.0 clean-css@3.4.12 requirejs uglify-js"
# sphinxdoc-install-npm-and-css-js-filters-end

Expand All @@ -150,7 +158,8 @@ setup_virtualenvwrapper () {
set +o nounset

# sphinxdoc-install-virtualenvwrapper-begin
$sudo pip install -U virtualenvwrapper setuptools pip
$sudo pip install -U setuptools pip
$sudo pip install -U virtualenvwrapper
if ! grep -q virtualenvwrapper ~/.bashrc; then
mkdir -p "$HOME/.virtualenvs"
echo "export WORKON_HOME=$HOME/.virtualenvs" >> "$HOME/.bashrc"
Expand Down Expand Up @@ -190,20 +199,31 @@ setup_nginx_centos7 () {
$sudo cp "$scriptpathname/../nginx/invenio3.conf" /etc/nginx/conf.d/
$sudo sed -i "s,/home/invenio/,/home/$(whoami)/,g" /etc/nginx/conf.d/invenio3.conf

# add SELinux permissions if necessary:
if $sudo getenforce | grep -q 'Enforcing'; then
if ! $sudo semanage port -l | tail -n +1 | grep -q '8888'; then
$sudo semanage port -a -t http_port_t -p tcp 8888
$sudo semanage port -a -t http_port_t -p tcp 8888
fi
if ! $sudo semanage port -l | grep ^http_port_t | grep -q 5000; then
$sudo semanage port -m -t http_port_t -p tcp 5000
fi
if ! $sudo getsebool -a | grep httpd | grep httpd_enable_homedirs | grep -q on; then
$sudo setsebool -P httpd_enable_homedirs 1
mkdir -p "/home/$(whoami)/.virtualenvs/${INVENIO_WEB_VENV}/var/${INVENIO_WEB_VENV}-instance/static"
$sudo chcon -R -t httpd_sys_content_t "/home/$(whoami)/.virtualenvs/${INVENIO_WEB_VENV}/var/${INVENIO_WEB_VENV}-instance/static"
fi
fi

$sudo sed -i 's,80,8888,g' /etc/nginx/nginx.conf
$sudo chmod go+rx "/home/$(whoami)/"
$sudo /sbin/service nginx restart

# open firewall:
$sudo firewall-cmd --permanent --zone=public --add-service=http
$sudo firewall-cmd --permanent --zone=public --add-service=https
$sudo firewall-cmd --reload
# open firewall ports:
if firewall-cmd --state | grep -q running; then
$sudo firewall-cmd --permanent --zone=public --add-service=http
$sudo firewall-cmd --permanent --zone=public --add-service=https
$sudo firewall-cmd --reload
fi
# sphinxdoc-install-web-nginx-centos7-end
}

Expand Down

0 comments on commit 5dc654e

Please sign in to comment.