Mac OS X: install lxml

  • Install xcode first
  • Run the command:
    xcode-select --install

Shell scripting: get the last argument

for last; do true; done
echo $last

Install MyTardis on Ubuntu Linux 16.04

  1. Create a service user account for running MyTardis:
    useradd -m -d /opt/mytardis -s /bin/bash tardis
  2. Check out MyTardis from github:
    cd /opt
    sudo git clone -b master
    sudo chown tardis:tardis /opt/mytardis
  3. Install required ubuntu packages:
    sudo bash /opt/mytardis/
  4. Setup virtualenv for tardis account:
    sudo su tardis
    source /usr/share/virtualenvwrapper/
    mkvirtualenv --system-site-packages mytardis
    pip install -U pip
    echo "source /usr/share/virtualenvwrapper/" >> ~/.bashrc
    echo "workon mytardis" >> ~/.bashrc
    source ~/.bashrc
  5. (As user 'tardis',) To work around this bleach bug, set html5lib version by adding line below to requirements.txt:
  6. remove billiard from requirements.txt or after installing the required packages, re-install celery package to downgrade billiard to This is because the installed billiard is installed and it causes celery failed to process any task. (Thread ResultHandler crashed: TypeError ...)
  7. (As user 'tardis',) Install required Python packages:
    cd /opt/mytardis
    pip install -U -r requirements.txt
  8. (As user 'tardis',) Initialize tardis/ (as user 'tardis'):
    cd /opt/mytardis
    mv tardis/ tardis/
    add the following lines:
    DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
    DATABASES['default']['NAME'] = 'tardis_db'
  9. (As user 'tardis',) Generate SECRET_KEY and save to tardis/
    echo "SECRET_KEY='`python generate_secret_key`'" >> tardis/
    or to re-generate:
    python -c "import os; from random import choice; key_line = '%sSECRET_KEY=\"%s\"  # generated from\n' % ('from tardis.default_settings import * \n\n' if not os.path.isfile('tardis/') else '', ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789\\!@#$%^&*(-_=+)') for i in range(50)])); f=open('tardis/', 'a+'); f.write(key_line); f.close()"
  10. (As user 'tardis',) Initialize database:
    python migrate
  11. (As user 'tardis',) Create cache tables:
    python createcachetable default_cache
    python createcachetable celery_lock_cache
  12. (As user 'tardis',) Collect static files and save to static/ directory under /opt/mytardis:
    python collectstatic
  13. (As user 'tardis',) Create superuser (as user 'tardis'):
    python createsuperuser
  14. (As user 'tardis',) Create var/store directory:
    mkdir -p var/store
  15. (As user 'tardis',) Start mytardis server:
    python celeryd &
    python runserver
    Note: 1) celeryd has to be started manually prior mytardis; 2) append to runserver command will make the server serve other hosts rather than only localhost:8000
  16. Supervisor can be installed to auto-start celeryd and webserver...