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