Commit 2ce3dbd6 by Bruno Bzeznik

Added phylodump loading if available

parent 48abb3a0
#!/usr/bin/env bash
source_dir=$1
phylodump_dir=$2
if [ "$source_dir" = "" ]
then
echo "usage: $0 <phylodb_source_directory>"
echo "usage: $0 <phylodb_source_directory> [phylodump_directory]"
exit 1
fi
......@@ -19,6 +20,12 @@ init_script=`nix-store --add store/init.sh`
source_dir=`nix-store --add $source_dir`
run mkdir -p /var/lib/phyloalps/phylodb
run cp -a $source_dir/* /var/lib/phyloalps/phylodb/
if [ "$phylodump_dir" \!= "" ]
then
phylodump_dir=`nix-store --add $phylodump_dir`
run mkdir -p /var/lib/phyloalps/phylodump
run cp -a $phylodump_dir/* /var/lib/phyloalps/phylodump/
fi
run mkdir -p /var/lib/phyloalps/phylodb/log
run touch /var/lib/phyloalps/phylodb/log/debug.log
run chown -R phyloalps /var/lib/phyloalps
......
......@@ -2,6 +2,7 @@
LIB_DIR=/var/lib
PHYLODB_DIR=$LIB_DIR/phyloalps/phylodb
PHYLODUMP_DIR=$LIB_DIR/phyloalps/phylodump
# Config
echo 'GEOS_LIBRARY_PATH = "/run/current-system/sw/lib/libgeos_c.so"' >> $PHYLODB_DIR/phylodb/settings.py
......@@ -12,7 +13,10 @@ perl -pi -e "s/CSRF_COOKIE_SECURE.*=.*/CSRF_COOKIE_SECURE = False/" $PHYLODB_DIR
# Django install
cd $LIB_DIR/django
virtualenv -p python3 phylodbenv
if [ \! -d phylodbenv ]
then
virtualenv -p python3 phylodbenv
fi
source phylodbenv/bin/activate
pip install django
pip install ply
......@@ -31,23 +35,35 @@ python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py migrate --database=browser_db
# Init the superuser
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'gridmaster@univ-grenoble-alpes.fr', 'phylodev')" | python3 manage.py shell
# Database initial data
if [ \! -f $PHYLODB_DIR/initdb.done ]
then
# Init the superuser
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'gridmaster@univ-grenoble-alpes.fr', 'phylodev')" | python3 manage.py shell
# Load sample data
latest_sample=`ls samples/*[0-9].csv|sort -n|tail -1`
sudo -u phyloalps python3 install/load_sampling_data.py $latest_sample browser_db phylobrowser
sudo -u phyloalps python3 install/load_sampling_data.py $latest_sample editor_db phyloeditor
# Load data
if [ -f $PHYLODUMP_DIR/phylodb_dump.json ]
then
## Loading from a dump
echo "Dump found, loading it..."
python3 manage.py loaddata $PHYLODUMP_DIR/phylodb_dump.json
else
## Direct loading
# Load sample data
latest_sample=`ls samples/*[0-9].csv|sort -n|tail -1`
sudo -u phyloalps python3 install/load_sampling_data.py $latest_sample browser_db phylobrowser
sudo -u phyloalps python3 install/load_sampling_data.py $latest_sample editor_db phyloeditor
# Reverse geocode the samples GPS coordinates
# TODO: save samples into a file, to by-pass the need of the online Geonames.org api
# sudo -u phyloalps python3 install/reverse_geocode.py browser_db phylobrowser
# sudo -u phyloalps python3 install/reverse_geocode.py editor_db phyloeditor
# Reverse geocode the samples GPS coordinates
#sudo -u phyloalps python3 install/reverse_geocode.py browser_db phylobrowser
#sudo -u phyloalps python3 install/reverse_geocode.py editor_db phyloeditor
# Load the genomic data
# TODO: this is very long - Maybe prepare a DB daily outside and load an SQL dump here?
#sudo -u phyloalps python3 install/load_genomic_data.py browser_db phylobrowser
#sudo -u phyloalps python3 install/load_genomic_data.py editor_db phyloeditor
# Load the genomic data
#sudo -u phyloalps python3 install/load_genomic_data.py browser_db phylobrowser
#sudo -u phyloalps python3 install/load_genomic_data.py editor_db phyloeditor
fi
touch $PHYLODB_DIR/initdb.done
fi
# Download the project dependencies
if [ \! -d phylodb/static/deps/bulma* ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment