-
Notifications
You must be signed in to change notification settings - Fork 4
Install Script 2.5.2
Krzysiek Madejski edited this page Apr 19, 2016
·
2 revisions
#!/bin/bash
:' This script is a valid Markdown document and bash script in its raw form. It's advised to run script partly to handle errors that may come up due to different server configuration.'
:' This script was tested on: Ubuntu 14.04 LTS.'
:' Requirements versions: Postgres 9.0 or later.'
:' WARNING: This version for 2.5.2 is a draft.'
apt-get update
apt-get -y install python-dev postgresql libpq-dev python-pip solr-jetty vim build-essential libxslt1-dev libxml2-dev git supervisor
apt-get -y install apache2 libapache2-mod-wsgi # If using apache
# Install Oracle JDK
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u77-b03/server-jre-8u77-linux-x64.tar.gz
mkdir /opt/jdk
tar -zxvf server-jre-8u77-linux-x64.tar.gz -C /opt/jdk
update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_77/bin/java 4108077
rm server-jre-8u77-linux-x64.tar.gz
adduser ckan
adduser ckan sudo # For convenience, will be unsudoed later
adduser datapusher --system --no-create-home
addgroup ckan-logs
addgroup ckan-data
adduser www-data ckan-logs
adduser www-data ckan-data
adduser datapusher ckan-data
adduser datapusher ckan-logs
mkdir /var/log/ckan -m=775 # All logs go there [webserver, datapusher, celeryd]
chown ckan:ckan-logs /var/log/ckan
ln -s /var/log/jetty/ /var/log/ckan/solr-jetty
chmod 755 /var/log/jetty
sudo -u ckan mkdir /home/ckan/data -m=775
sudo -u ckan mkdir /home/ckan/data/archiver -m=775
chgrp -R ckan-data /home/ckan/data
:'see: http://simononsoftware.com/virtualenv-tutorial-part-2/'
pip install virtualenvwrapper
# Autoloads environment, so you can type anytime 'workon'
echo 'export WORKON_HOME=$HOME/.virtualenvs' >> /home/ckan/.bashrc
echo 'source /usr/local/bin/virtualenvwrapper_lazy.sh' >> /home/ckan/.bashrc
:' TODO: create ckanext-danepubliczne containing config files'
su ckan
cd /home/ckan
mkdir ~/.virtualenvs
mkvirtualenv ckan -p /usr/bin/python2.7
pip install -e git+https://github.com/ckan/[email protected]#egg=ckan
pip install -e git+https://github.com/DanePubliczneGovPl/ckanext-danepubliczne@release/0.1.1#egg=ckanext-danepubliczne
pip install -e git+https://github.com/ckan/ckanext-archiver.git#egg=ckanext-archiver
pip install -e git+https://github.com/datagovuk/ckanext-report.git#egg=ckanext-report
pip install -e git+https://github.com/okfn/ckanext-qa.git#egg=ckanext-qa
ln -s /home/ckan/.virtualenvs/ckan/src /home/ckan/src
pip install -r /home/ckan/src/ckan/requirements.txt
pip install -r /home/ckan/src/ckanext-archiver/requirements.txt
pip install -r /home/ckan/src/ckanext-qa/requirements.txt
mkvirtualenv datapusher -p /usr/bin/python2.7
pip install -e git+https://github.com/ckan/[email protected]#egg=datapusher
pip install -r /home/ckan/.virtualenvs/datapusher/src/datapusher/requirements.txt
workon ckan
:'Update config files residing in /home/ckan/src/ckanext-danepubliczne/config if you did not follow exactly this configuration' :' TODO: create ckanext-danepubliczne containing config files for bare CKAN'
cd /home/ckan/src/ckanext-danepubliczne/config
sudo mkdir /etc/ckan
cp prod.default.ini prod.ini
rm template.ini 2>/dev/null
paster make-config ckan template.ini > /dev/null # Creates unique values for some settings
grep beaker.session.secret template.ini >> prod.ini
grep app_instance_uuid template.ini >> prod.ini
vim +/"Make sure following settings are correct" prod.ini
sudo cp prod.ini /etc/ckan/
sudo cp who.ini /etc/ckan/
sudo cp ckan.py /etc/ckan/
sudo cp celery-supervisor.conf /etc/supervisor/conf.d/ckan-celery.conf
sudo cp jetty /etc/default/jetty
sudo cp /home/ckan/src/ckan/ckan/config/solr/schema.xml /etc/solr/conf/schema.xml
sudo cp datapusher.apache2-4.conf /etc/apache2/sites-available/datapusher.conf
sudo cp ckan.conf /etc/apache2/sites-available/000-ckan.conf
sudo cp datapusher.wsgi /etc/ckan/
sudo cp datapusher_settings.py /etc/ckan/
# export CKAN_INI so it doesn't have to be specified on command line
export CKAN_INI=/etc/ckan/prod.ini
echo 'export CKAN_INI=/etc/ckan/prod.ini' >> /home/ckan/.bashrc
# Fix for Ubuntu 14.04
sudo sh -c 'echo /usr/share/java/tomcat-coyote.jar >> /etc/jetty/start.config'
# open up port 8800 on Apache where the DataPusher accepts connections.
# make sure this line appear only once in /etc/apache2/ports.conf.
sudo sh -c 'echo "Listen 8800" >> /etc/apache2/ports.conf'
sudo sh -c 'echo "ServerName danepubliczne.gov.pl" >> /etc/apache2/apache2.conf'
sudo a2ensite 000-ckan
sudo a2ensite datapusher
sudo rm /etc/apache2/sites-enabled/000-default.conf > /dev/null
sudo -u postgres psql -c "CREATE USER ckan WITH PASSWORD 'ckan';"
sudo -u postgres createdb -O ckan ckan -E utf-8
sudo -u postgres psql -c "CREATE USER datastore WITH PASSWORD 'datastore';"
sudo -u postgres createdb -O ckan datastore -E utf-8
sudo service jetty start
paster --plugin=ckan datastore set-permissions | sudo -u postgres psql --set ON_ERROR_STOP=1
paster --plugin=ckan db init
paster --plugin=ckanext-archiver archiver init
paster --plugin=ckanext-report report initdb
paster --plugin=ckanext-qa qa init
sudo apt-get -y install unzip libapache2-mod-php5 php5 php5-mysql mysql-server
cd /home/ckan
wget http://builds.piwik.org/piwik.zip
unzip piwik.zip
rm "How to install Piwik.html" piwik.zip
cd piwik
sudo chgrp -R www-data tmp config
sudo chmod g+w -R tmp config
# Webserver
sudo apachectl restart
# Celery tasks run by supervisor
sudo supervisorctl reread
sudo supervisorctl update
# Page tracking
sudo sh -c 'echo "@hourly ckan paster --plugin=ckan tracking update && paster --plugin=ckan search-index rebuild -r" > /etc/cron.d/ckan-tracking'
# Use this api-key to import data (optionally)
sudo -u postgres psql -d ckan -c "SELECT apikey FROM public.user WHERE name = 'danepubliczne.gov.pl';"
# TODO open http://stats.danepubliczne.gov.pl and configure piwik
# Lock password access & remove ckan from sudo
sudo usermod --lock ckan
sudo deluser ckan sudo