Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
galaxyproject
GitHub Repository: galaxyproject/training-material
Path: blob/main/bin/docker-install-tutorials.sh
1677 views
1
#!/bin/bash
2
3
# set API key
4
API_KEY=${GALAXY_DEFAULT_ADMIN_KEY:-fakekey}
5
6
# Enable Test Tool Shed
7
echo ".. Setting up conda"
8
export GALAXY_CONFIG_TOOL_SHEDS_CONFIG_FILE=$GALAXY_HOME/tool_sheds_conf.xml
9
10
. /tool_deps/_conda/etc/profile.d/conda.sh
11
conda activate base
12
13
if pgrep "supervisord" > /dev/null
14
then
15
echo ".. System is up and running. Starting with the installation."
16
export PORT=80
17
else
18
# start Database
19
echo ".. Starting database"
20
export PORT=8080
21
service postgresql start
22
install_log='galaxy_install.log'
23
24
# wait for database to finish starting up
25
STATUS=$(psql 2>&1)
26
while [[ ${STATUS} =~ "starting up" ]]
27
do
28
echo ".. Waiting for database: $STATUS"
29
STATUS=$(psql 2>&1)
30
sleep 1
31
done
32
# start Galaxy
33
echo ".. Starting Galaxy"
34
# Unset SUDO_* vars otherwise conda run chown based on that
35
sudo -E -u galaxy -- bash -c "unset SUDO_UID; \
36
unset SUDO_GID; \
37
unset SUDO_COMMAND; \
38
unset SUDO_USER; \
39
./run.sh -d $install_log --pidfile galaxy_install.pid --http-timeout 3000"
40
41
galaxy_install_pid=`cat galaxy_install.pid`
42
galaxy-wait -g http://localhost:$PORT -v --timeout 120
43
echo ".. Galaxy is running"
44
fi
45
46
# Create the admin user if not already done
47
# Starting with 20.05 this user is only created at first startup of galaxy
48
# We need to create it here for Galaxy Flavors = installing from Dockerfile
49
if [[ ! -z $GALAXY_DEFAULT_ADMIN_USER ]]
50
then
51
(
52
cd $GALAXY_ROOT
53
. $GALAXY_VIRTUAL_ENV/bin/activate
54
echo ".. Creating admin user $GALAXY_DEFAULT_ADMIN_USER with key $GALAXY_DEFAULT_ADMIN_KEY and password $GALAXY_DEFAULT_ADMIN_PASSWORD if not existing"
55
python /usr/local/bin/create_galaxy_user.py --user "$GALAXY_DEFAULT_ADMIN_EMAIL" --password "$GALAXY_DEFAULT_ADMIN_PASSWORD" \
56
-c "$GALAXY_CONFIG_FILE" --username "$GALAXY_DEFAULT_ADMIN_USER" --key "$GALAXY_DEFAULT_ADMIN_KEY"
57
)
58
fi
59
60
# install tutorial materials
61
echo ".. Starting installation of the tutorials."
62
for tutdir in $topicdir/tutorials/*
63
do
64
echo "-------------------------------------------------------------"
65
tut=$(basename $tutdir)
66
echo "Installing tutorial: $tut"
67
# install tools and workflows
68
if [ -d $tutdir/workflows/ ];
69
then
70
echo " - Extracting tools from workflows"
71
for w in $tutdir/workflows/*.ga
72
do
73
workflow-to-tools -w $w -o $tutdir/workflows/wftools.yaml -l $tut
74
echo " - Installing tools from workflow $(basename $w)"
75
n=0
76
until [ $n -ge 3 ]
77
do
78
shed-tools install -t $tutdir/workflows/wftools.yaml -g "http://localhost:$PORT" -a $API_KEY && break
79
n=$[$n+1]
80
sleep 5
81
echo " - Retrying shed-tools install "
82
done
83
rm $tutdir/workflows/wftools.yaml
84
done
85
echo " - Installing workflows"
86
workflow-install --publish_workflows --workflow_path $tutdir/workflows/ -g "http://localhost:$PORT" -a $API_KEY
87
else
88
echo " - No workflows to install (no directory named workflows present)"
89
fi
90
91
92
# install reference data? (discussion: do this at build or run time?)
93
# We are using CVMFS for the moment.
94
#if [ -f $dir/data-manager.yaml ]
95
#then
96
# echo " - Installing reference data"
97
# run-data-managers --config $dir/data-manager.yaml -g $galaxy_instance -u $GALAXY_DEFAULT_ADMIN_USER -p $GALAXY_DEFAULT_ADMIN_PASSWORD
98
#else
99
# echo " - No reference data to install (no file named data-manager.yaml present)"
100
#fi
101
102
# install tours
103
if [ -d $tutdir/tours/ ];
104
then
105
echo " - Installing tours"
106
for t in $tutdir/tours/*
107
do
108
fname=$tut-$(basename $t)
109
echo " - Installing tour: $t as $fname"
110
cp $t $GALAXY_ROOT/config/plugins/tours/$fname
111
done
112
else
113
echo " - No tours to install (no directory named tours present)"
114
fi
115
116
echo " - Finished installation of $tut tutorial"
117
done
118
119
echo "-------------------------------------------------------------"
120
echo ".. Generating data-library_all.yaml file"
121
cd /tutorials/
122
python /mergeyaml.py > ./data-library_all.yaml
123
124
exit_code=$?
125
126
if [ $exit_code != 0 ] ; then
127
if [ "$2" == "-v" ] ; then
128
echo ".. Installation failed, Galaxy server log:"
129
cat $install_log
130
fi
131
exit $exit_code
132
fi
133
134
if ! pgrep "supervisord" > /dev/null
135
then
136
echo ".. Shutting down Galaxy and postgresql"
137
# stop everything
138
sudo -E -u galaxy /galaxy-central/run.sh --stop --pidfile /galaxy-central/galaxy_install.pid
139
rm /galaxy-central/$install_log
140
service postgresql stop
141
fi
142
143
echo ".. Installation is finished"
144
145