diff --git a/galaxy/Dockerfile b/galaxy/Dockerfile index db101250b..b7d33f47e 100644 --- a/galaxy/Dockerfile +++ b/galaxy/Dockerfile @@ -235,6 +235,8 @@ ADD ./tool_sheds_conf.xml $GALAXY_HOME/tool_sheds_conf.xml # Script that enables easier downstream installation of tools (e.g. for different Galaxy Docker flavours) ADD install_tools_wrapper.sh /usr/bin/install-tools +ADD with-galaxy.sh /usr/bin/with-galaxy + # script to install BioJS visualizations ADD install_biojs_vis.sh /usr/bin/install-biojs RUN chmod +x /usr/bin/install-tools /usr/bin/install-biojs && \ diff --git a/galaxy/with-galaxy.sh b/galaxy/with-galaxy.sh new file mode 100755 index 000000000..2c3879333 --- /dev/null +++ b/galaxy/with-galaxy.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Enable Test Tool Shed +export GALAXY_CONFIG_TOOL_SHEDS_CONFIG_FILE=$GALAXY_HOME/tool_sheds_conf.xml + +if pgrep "supervisord" > /dev/null +then + echo "System is up and running. Starting with the installation." + export PORT=80 +else + # start Galaxy + export PORT=8080 + service postgresql start + install_log='galaxy_install.log' + + # wait for database to finish starting up + STATUS=$(psql 2>&1) + while [[ ${STATUS} =~ "starting up" ]] + do + echo "waiting for database: $STATUS" + STATUS=$(psql 2>&1) + sleep 1 + done + + echo "starting Galaxy" + sudo -E -u galaxy unset $SUDO_UID; ./run.sh -d $install_log --pidfile galaxy_install.pid --http-timeout 3000 + + galaxy_install_pid=`cat galaxy_install.pid` + galaxy-wait -g http://localhost:$PORT -v --timeout 120 +fi + +exec "$@" + +exit_code=$? + +if [ $exit_code != 0 ] ; then + if [ "$2" == "-v" ] ; then + echo "Command failed, Galaxy server log:" + cat $install_log + fi + # exit $exit_code Galaxy should be shut down properly +fi + +if ! pgrep "supervisord" > /dev/null +then + # stop everything + sudo -E -u galaxy ./run.sh --stop --pidfile galaxy_install.pid + rm $install_log + service postgresql stop +fi + +exit $exit_code