#!/bin/bash

set -e

cat <<EOF
## THIS SCRIPT WILL CONVERT THIS INSTALLATION OF
## THE OPENQUAKE ENGINE FROM THE "STABLE" BRANCH
## TO THE "MASTER" DEVELOPMENT BRANCH'
## ANY CHANGED MADE TO THE CODE IN 'oq-engine'
## WILL BE LOST

EOF


systemctl --user stop openquake-webui openquake-dbserver
cd $HOME/GEM
rm -Rf oq-engine
git clone https://github.com/gem/oq-engine
pip install -e oq-engine

cd oq-platform
for d in oq-*; do
    rm -Rf $d
git clone https://github.com/gem/$d
pip install -e $d
done
systemctl --user start openquake-dbserver openquake-webui

echo "## OPERATION COMPLETED SUCESSFULLY"
