11#! /bin/bash
2+ set -euo pipefail
23
34# Clean cache
45rm -rf " $HOME /.ivy2/local/org.reactivemongo"
@@ -17,28 +18,42 @@ SSL_MAJOR="1.0.0"
1718SSL_SUFFIX=" 10"
1819SSL_RELEASE=" 1.0.2"
1920SSL_FULL_RELEASE=" 1.0.2u"
20- SSL_DL_URL=" https://www.openssl.org/source/old/$SSL_RELEASE /openssl-$SSL_FULL_RELEASE .tar.gz"
21+ SSL_GH_TAG=" OpenSSL_1_0_2u"
22+ SSL_DL_URL=" https://github.com/openssl/openssl/releases/download/${SSL_GH_TAG} /openssl-${SSL_FULL_RELEASE} .tar.gz"
23+ SSL_HOME=" $HOME /ssl"
24+ SSL_LIB=" $SSL_HOME /lib"
2125
22- if [ ! -L " $HOME /ssl/lib/ libssl.so.$SSL_MAJOR " ] && [ ! -f " $HOME /ssl/lib /libcrypto.so.$SSL_MAJOR " ]; then
26+ if [ ! -f " $SSL_LIB / libssl.so.$SSL_MAJOR " ] || [ ! -f " $SSL_LIB /libcrypto.so.$SSL_MAJOR " ]; then
2327 echo " [INFO] Building OpenSSL $SSL_MAJOR ..."
2428
2529 cd /tmp
2630
2731 echo " [INFO] Downloading OpenSSL from $SSL_DL_URL ..."
28- curl -L -s -o - " $SSL_DL_URL " | tar -xzf -
32+ curl -fL -s -o - " $SSL_DL_URL " | tar -xzf -
2933
30- cd openssl-$SSL_FULL_RELEASE
31- rm -rf " $HOME /ssl" && mkdir " $HOME /ssl"
32- ./config -shared enable-ssl2 --prefix=" $HOME /ssl" > /dev/null
34+ cd " openssl-${SSL_FULL_RELEASE} "
35+ rm -rf " $SSL_HOME " && mkdir " $SSL_HOME "
36+
37+ echo " [INFO] Configuring OpenSSL build ..."
38+ ./config -shared enable-ssl2 --prefix=" $SSL_HOME " > /dev/null
39+
40+ echo " [INFO] Resolving dependencies for OpenSSL build ..."
3341 make depend > /dev/null
42+
43+ echo " [INFO] Building and installing OpenSSL ..."
3444 make install > /dev/null
45+ fi
3546
36- ln -s " $HOME /ssl/lib/libssl.so.$SSL_MAJOR " " $HOME /ssl/lib/libssl.so.$SSL_SUFFIX "
37- ln -s " $HOME /ssl/lib/libcrypto.so.$SSL_MAJOR " " $HOME /ssl/lib/libcrypto.so.$SSL_SUFFIX "
47+ if [ ! -d " $SSL_LIB " ] || [ ! -f " $SSL_LIB /libssl.so.$SSL_MAJOR " ] || [ ! -f " $SSL_LIB /libcrypto.so.$SSL_MAJOR " ]; then
48+ echo " [ERROR] OpenSSL libraries are missing in $SSL_LIB "
49+ exit 1
3850fi
3951
40- export PATH=" $HOME /ssl/bin:$PATH "
41- export LD_LIBRARY_PATH=" $HOME /ssl/lib:$LD_LIBRARY_PATH "
52+ ln -sf " $SSL_LIB /libssl.so.$SSL_MAJOR " " $SSL_LIB /libssl.so.$SSL_SUFFIX "
53+ ln -sf " $SSL_LIB /libcrypto.so.$SSL_MAJOR " " $SSL_LIB /libcrypto.so.$SSL_SUFFIX "
54+
55+ export PATH=" $SSL_HOME /bin:$PATH "
56+ export LD_LIBRARY_PATH=" $SSL_LIB :${LD_LIBRARY_PATH:- } "
4257
4358# Build MongoDB
4459MONGO_MINOR=" 3.6.6"
@@ -60,6 +75,12 @@ if [ ! -x "$MONGO_HOME/bin/mongod" ]; then
6075 chmod u+x " $MONGO_HOME /bin/mongod"
6176fi
6277
78+ if ldd " $MONGO_HOME /bin/mongod" | grep -q ' not found' ; then
79+ echo " [ERROR] Missing shared libraries for $MONGO_HOME /bin/mongod"
80+ ldd " $MONGO_HOME /bin/mongod"
81+ exit 1
82+ fi
83+
6384echo " [INFO] MongoDB available at $MONGO_HOME "
6485
6586PATH=" $MONGO_HOME /bin:$PATH "
@@ -82,9 +103,26 @@ echo " maxIncomingConnections: $MAX_CON" >> /tmp/mongod.conf
82103echo " # MongoDB Configuration:"
83104cat /tmp/mongod.conf
84105
106+ for cmd in mongod mongo; do
107+ if command -v " $cmd " > /dev/null 2>&1 ; then
108+ echo " [INFO] $cmd location: $( command -v " $cmd " ) "
109+ else
110+ echo " [ERROR] Missing executable: $cmd "
111+ exit 1
112+ fi
113+ done
114+
115+ if ldd " $( command -v mongo) " | grep -q ' not found' ; then
116+ echo " [ERROR] Missing shared libraries for $( command -v mongo) "
117+ ldd " $( command -v mongo) "
118+ exit 1
119+ fi
120+
85121# Export environment for integration tests
86122
87123cat > /tmp/integration-env.sh << EOF
88- PATH="$PATH "
89- LD_LIBRARY_PATH="$LD_LIBRARY_PATH "
124+ export PATH="$PATH "
125+ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH "
90126EOF
127+
128+ echo " [INFO] Integration environment exported to /tmp/integration-env.sh"
0 commit comments