rebuild-ontohub revision 37cc69ff6c896d2259221d7f912c3a4113cbfccb
346N/A#!/bin/bash
346N/A
346N/Aabort_unless_invoker_installed() {
346N/A result="$(which invoker 2>&1)"
346N/A if [[ "$?" -ne "0" ]]; then
346N/A echo ">>> Invoker not installed, please install"
346N/A exit 1
346N/A fi
346N/A}
346N/A
346N/Ainitialize_new_invoker_instance() {
346N/A result="$(invoker list 2>&1)"
346N/A if [[ "$?" -eq "0" ]]; then
346N/A echo ">>> Invoker running, restarting..."
346N/A result=`invoker stop 2>&1`
346N/A else
346N/A echo ">>> Invoker not running, starting..."
346N/A fi
346N/A invoker start invoker.ini --daemon
346N/A}
346N/A
346N/Aexecute_or_die() {
3817N/A cmd="$1"
346N/A echo ">>> Executing '$cmd'"
346N/A result="$($cmd 2>&1)"
3817N/A state="$?"
3817N/A if [[ "$state" -ne "0" ]]; then
3817N/A echo "$result"
346N/A echo ">>> Failed to execute '$cmd', aborting further commands."
346N/A exit 1
4162N/A fi
783N/A}
1244N/A
4162N/Aabort_unless_invoker_installed
618N/Ainitialize_new_invoker_instance
1244N/A
1244N/Afor i in "$@"; do
4162N/Acase $i in
844N/A -d|--download-fixtures)
4162N/A export DOWNLOAD_FIXTURES=true
618N/A ;;
1258N/A -r|--restart)
346N/A RESTART_INVOKER_ONLY=true
346N/A ;;
346N/A *)
346N/A # unknown option
4162N/A ;;
844N/A esac
4162N/A shift
618N/Adone
4194N/A
4194N/Aif [[ !($RESTART_INVOKER_ONLY) ]]; then
346N/A execute_or_die "bundle exec rake elasticsearch:wipe"
346N/A execute_or_die "bundle exec rake db:migrate:clean"
346N/A execute_or_die "redis-cli flushdb"
346N/A execute_or_die "bundle exec rake git:compile_cp_keys"
4162N/A execute_or_die "bundle exec rake db:seed"
844N/Afi
4162N/A