Last active
July 5, 2017 05:26
-
-
Save pansapiens/b88344b6284464c66eebca167bcec9ef to your computer and use it in GitHub Desktop.
Setup MyTardis on Ubuntu 14.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# For MyTardis 3.7 - YMMV for other versions | |
set USER=ubuntu | |
set MYTARDIS_ADMIN_NAME=admin | |
set [email protected] | |
set MYTARDIS_DATA_DIR=/data/mytardis | |
set SETUP_DYNAMIC_DNS=no | |
set CREATE_DATA_VOLUME=no | |
git clone https://github.com/mytardis/mytardis | |
cd mytardis | |
# for Ubuntu 14.04 | |
sudo apt-get update -y | |
sudo apt-get -y install python-pip git libxml2-dev libxslt1-dev python-dev zlib1g-dev python-wand \ | |
python-virtualenv virtualenvwrapper python-psycopg2 python-yaml ipython \ | |
python-anyjson python-bs4 python-billiard python-feedparser python-html5lib \ | |
python-httplib2 python-pystache python-crypto python-flexmock python-dateutil libfreetype6-dev \ | |
libldap2-dev libsasl2-dev | |
# If you want to run the Celery task queue (hint: you probably do) | |
sudo apt-get -y install rabbitmq-server | |
# optionally: | |
sudo apt-get install memcached python-memcache | |
sudo apt-get install postgresql | |
sudo -u postgres createuser mytardis | |
sudo -u postgres createdb --owner mytardis mytardis | |
# set the mytardis user password as xxx | |
echo "ALTER user mytardis with password 'xxx';" | sudo -u postgres psql mytardis | |
if [ $SETUP_DYNAMIC_DNS == 'yes' ] | |
then | |
# setup dynamic DNS, for convenience | |
sudo apt-get install inadyn | |
# TODO: setup dynamic DNS config and enable inadyn | |
# 1. echo out a /etc/inadyn.conf file | |
# 2. Run sed on /etc/default/inadyn to enable | |
sudo /etc/init.d/inadyn start | |
# ASSIGNED_HOSTNAME can be something used at the dynamic DNS service, | |
# or we can get the automatically assigned OpenStack FQDN | |
set ASSIGNED_HOSTNAME=$(curl http://169.254.169.254/latest/meta-data/hostname) | |
sudo hostnamectl set-hostname $ASSIGNED_HOSTNAME | |
# TODO: also update FQDN in /etc/hosts | |
fi | |
if [ $CREATE_DATA_VOLUME == 'yes' ] | |
then | |
# attach (and possibly format !) a persistent NeCTAR volume | |
# sudo mkfs.ext4 /dev/vdc | |
# sudo mkdir -p "${MYTARDIS_DATA_DIR}" | |
# sudo mount /dev/vdc "${MYTARDIS_DATA_DIR}" -t auto | |
# make raw data readonly | |
#sudo chmod -R a-w "${MYTARDIS_DATA_DIR}"/ | |
#sudo chown -R $USER.$USER "${MYTARDIS_DATA_DIR}" | |
fi | |
# for Ubuntu 14.04 | |
virtualenv --system-site-packages ./virtualenv | |
source ./virtualenv/bin/activate | |
pip install -U pip | |
pip install -r requirements.txt | |
# pip install bleach==2.0.0 flexmock==0.10.2 pystache==0.5.4 | |
# Just for tests. Silly. | |
mkdir -p var/store | |
# execute this wonderful command to have your settings.py created/updated | |
# with a generated Django SECRET_KEY (required for MyTardis to run) | |
python -c "import os, string; from random import choice; key_line = '%sSECRET_KEY=\"%s\" # generated from build.sh\n' % ('from tardis.settings_changeme import * \n\n' if not os.path.isfile('tardis/settings.py') else '', ''.join([choice(string.ascii_letters+string.digits+'\\!@#$%^&*(-_=+)') for i in range(64)])); f=open('tardis/settings.py', 'a+'); f.write(key_line); f.close()" | |
# Now might be a good time to edit settings.py with other configuration | |
# You might want to change the DATABASES setting to use the Postgres database created above | |
python test.py | |
python mytardis.py migrate | |
python mytardis.py createcachetable default_cache | |
python mytardis.py createcachetable celery_lock_cache | |
python mytardis.py collectstatic | |
# if run in a non-interactive shell no admin password will be set - it must be | |
# set manually using python mytardis.py changepassword $MYTARDIS_ADMIN_NAME | |
python mytardis.py createsuperuser --noinput --username $MYTARDIS_ADMIN_NAME --email $MYTARDIS_ADMIN_EMAIL | |
# python mytardis.py changepassword $MYTARDIS_ADMIN_NAME | |
# TODO: this should be run under supervisor | |
python mytardis.py runserver | |
# In development, run Celery with the -Ofair scheduling flag | |
python mytardis.py celeryd -B -E -Ofair | |
# TODO: also run the celery queue (first) under supervisor | |
# In production you might turn off 'events' and fair scheduling, but 'fair' is better for debugging | |
# python mytardis.py celeryd -B | |
# Run the in-built SFTP server | |
python mytardis.py sftpd --host=0.0.0.0 --port=2200 | |
# build docs into docs (sphinx-build inputfolder outputfolder) | |
#sphinx-build docs docs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment