-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathomtd-component-ingestion.sh
executable file
·123 lines (106 loc) · 3.27 KB
/
omtd-component-ingestion.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
# Script for
# A. Generating Galaxy wrappers
# B. Pushing the respective images to the specified Docker Registry (if required)
# C. Copying Galaxy wrappers to the respective Galaxy instances (specifically to tool directory).
clear
# -- Script parameters
DockerRegistyHOST=$1
OMTDSHAREDescriptorsFolderRoot=$2
OMTDSHAREDescriptorsFolder=$3
GalaxyID=$4
#ComponentID=$5
#ComponentVersion=$6
Dockerfile=$5
DockerID=$6
DockerVersion=$7
Push=$8
DockerImg="NOTPROVIDED"
DockerImgTag="NOTPROVIDED"
GalaxyExecutorLoc=$9
echo "args:"$@
echo $DockerID
echo $DockerVersion
echo $Push
# --
# Before everything build project.
mvn clean install
# Clean wrappers dir
echo "Clean wrappers dir"
wrappersDir=$OMTDSHAREDescriptorsFolderRoot$OMTDSHAREDescriptorsFolder"_wrappers"
rm $wrappersDir/*
# If dockerfile is provided
# then build DockerImg, DockerImgTag values.
if [ $Dockerfile != "none" ]; then
# Docker image name.
DockerImg="omtd-component-executor-"${DockerID}":"${DockerVersion}
# Docker image tag.
DockerImgTag="${DockerRegistyHOST}/openminted/${DockerImg}"
echo "-----"
echo "Dockerfile:"$Dockerfile
echo "DockerImg:"$DockerImg
else
# DockerImg is not required
DockerImg=""
# A DockerImgTag is provided.
DockerImgTag=${10}
fi
echo "DockerImgTag:"$DockerImgTag
echo "-----"
# Generate
# * Galaxy Wrappers
# * TDMCoordinatesList file (only for Maven-based components)
# from omtd-share descriptors
# ~~~~~~~~~~~~~~~~~~~~~
#suffix=".wrapper."$ComponentID"."$ComponentVersion".xml"
suffix=".xml"
echo "Generate galaxy wrappers and TDMCoordinatesList"
java -jar ./omtd-component-galaxy/target/omtd-component-galaxy-0.0.1-SNAPSHOT-exec.jar $OMTDSHAREDescriptorsFolderRoot $OMTDSHAREDescriptorsFolder $GalaxyID $DockerImgTag $suffix
# If needed copy coordinates file.
GeneratedCoordinatesList=$OMTDSHAREDescriptorsFolderRoot$GalaxyID"coordinates.list"
if [ -f $GeneratedCoordinatesList ]; then
# Copy output coordinates to TDMCoordinatesList.txt
cat $GeneratedCoordinatesList > TDMCoordinatesList.txt
fi
# If dockerfile is provided
if [ $Dockerfile != "none" ]; then
# Build image.
echo "-- -- Build image"
sudo docker build -f $Dockerfile -t $DockerImg .
fi
# If specified Tag and Push image.
# ~~~~~~~~~~~~~~~~~~~~~
echo "Push:"$Push
if [ $Push == "yes" ]; then
# Tag the image for OMTD docker registry.
echo "-- -- Tag image"
#sudo docker tag -f $DockerImg $DockerImgTag
sudo docker tag $DockerImg $DockerImgTag
# Push it to OMTD docker Registry.
echo "-- -- Push image:"$DockerImgTag
sudo docker push $DockerImgTag
fi
# Ask
echo -e "\n\n"
read -p "Copy wrappers to Executor (y/n)?" choice
case "$choice" in
y|Y )
echo "yes"
# Now that image is pushed and is available to docker registry
# copy wrappers to target machine/dir so that everything appears in Galaxy UI.
# ~~~~~~~~~~~~~~~~~~~~~
echo "-- -- Copying wrappers"
wrappersDest=root@$GalaxyExecutorLoc:/srv/galaxy/tools/$GalaxyID
echo $wrappersDir
echo $wrappersDest
# Copying to Executor:
scp -r $wrappersDir/* $wrappersDest
# Copying to Editor: The tools dirs of Editor and Executor are synced via NFS so copying to Editor is deactivated.
#scp -r $wrappersDir/* [email protected]:/srv/galaxy/tools/$GalaxyID
;;
n|N )
echo "wrappers ... not copied";;
* )
echo "invalid"
;;
esac