Path: blob/main/bin/docker-install-tutorials.sh
1677 views
#!/bin/bash12# set API key3API_KEY=${GALAXY_DEFAULT_ADMIN_KEY:-fakekey}45# Enable Test Tool Shed6echo ".. Setting up conda"7export GALAXY_CONFIG_TOOL_SHEDS_CONFIG_FILE=$GALAXY_HOME/tool_sheds_conf.xml89. /tool_deps/_conda/etc/profile.d/conda.sh10conda activate base1112if pgrep "supervisord" > /dev/null13then14echo ".. System is up and running. Starting with the installation."15export PORT=8016else17# start Database18echo ".. Starting database"19export PORT=808020service postgresql start21install_log='galaxy_install.log'2223# wait for database to finish starting up24STATUS=$(psql 2>&1)25while [[ ${STATUS} =~ "starting up" ]]26do27echo ".. Waiting for database: $STATUS"28STATUS=$(psql 2>&1)29sleep 130done31# start Galaxy32echo ".. Starting Galaxy"33# Unset SUDO_* vars otherwise conda run chown based on that34sudo -E -u galaxy -- bash -c "unset SUDO_UID; \35unset SUDO_GID; \36unset SUDO_COMMAND; \37unset SUDO_USER; \38./run.sh -d $install_log --pidfile galaxy_install.pid --http-timeout 3000"3940galaxy_install_pid=`cat galaxy_install.pid`41galaxy-wait -g http://localhost:$PORT -v --timeout 12042echo ".. Galaxy is running"43fi4445# Create the admin user if not already done46# Starting with 20.05 this user is only created at first startup of galaxy47# We need to create it here for Galaxy Flavors = installing from Dockerfile48if [[ ! -z $GALAXY_DEFAULT_ADMIN_USER ]]49then50(51cd $GALAXY_ROOT52. $GALAXY_VIRTUAL_ENV/bin/activate53echo ".. Creating admin user $GALAXY_DEFAULT_ADMIN_USER with key $GALAXY_DEFAULT_ADMIN_KEY and password $GALAXY_DEFAULT_ADMIN_PASSWORD if not existing"54python /usr/local/bin/create_galaxy_user.py --user "$GALAXY_DEFAULT_ADMIN_EMAIL" --password "$GALAXY_DEFAULT_ADMIN_PASSWORD" \55-c "$GALAXY_CONFIG_FILE" --username "$GALAXY_DEFAULT_ADMIN_USER" --key "$GALAXY_DEFAULT_ADMIN_KEY"56)57fi5859# install tutorial materials60echo ".. Starting installation of the tutorials."61for tutdir in $topicdir/tutorials/*62do63echo "-------------------------------------------------------------"64tut=$(basename $tutdir)65echo "Installing tutorial: $tut"66# install tools and workflows67if [ -d $tutdir/workflows/ ];68then69echo " - Extracting tools from workflows"70for w in $tutdir/workflows/*.ga71do72workflow-to-tools -w $w -o $tutdir/workflows/wftools.yaml -l $tut73echo " - Installing tools from workflow $(basename $w)"74n=075until [ $n -ge 3 ]76do77shed-tools install -t $tutdir/workflows/wftools.yaml -g "http://localhost:$PORT" -a $API_KEY && break78n=$[$n+1]79sleep 580echo " - Retrying shed-tools install "81done82rm $tutdir/workflows/wftools.yaml83done84echo " - Installing workflows"85workflow-install --publish_workflows --workflow_path $tutdir/workflows/ -g "http://localhost:$PORT" -a $API_KEY86else87echo " - No workflows to install (no directory named workflows present)"88fi899091# install reference data? (discussion: do this at build or run time?)92# We are using CVMFS for the moment.93#if [ -f $dir/data-manager.yaml ]94#then95# echo " - Installing reference data"96# run-data-managers --config $dir/data-manager.yaml -g $galaxy_instance -u $GALAXY_DEFAULT_ADMIN_USER -p $GALAXY_DEFAULT_ADMIN_PASSWORD97#else98# echo " - No reference data to install (no file named data-manager.yaml present)"99#fi100101# install tours102if [ -d $tutdir/tours/ ];103then104echo " - Installing tours"105for t in $tutdir/tours/*106do107fname=$tut-$(basename $t)108echo " - Installing tour: $t as $fname"109cp $t $GALAXY_ROOT/config/plugins/tours/$fname110done111else112echo " - No tours to install (no directory named tours present)"113fi114115echo " - Finished installation of $tut tutorial"116done117118echo "-------------------------------------------------------------"119echo ".. Generating data-library_all.yaml file"120cd /tutorials/121python /mergeyaml.py > ./data-library_all.yaml122123exit_code=$?124125if [ $exit_code != 0 ] ; then126if [ "$2" == "-v" ] ; then127echo ".. Installation failed, Galaxy server log:"128cat $install_log129fi130exit $exit_code131fi132133if ! pgrep "supervisord" > /dev/null134then135echo ".. Shutting down Galaxy and postgresql"136# stop everything137sudo -E -u galaxy /galaxy-central/run.sh --stop --pidfile /galaxy-central/galaxy_install.pid138rm /galaxy-central/$install_log139service postgresql stop140fi141142echo ".. Installation is finished"143144145