This repository has been archived by the owner on Feb 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
requirements.sh
executable file
·209 lines (168 loc) · 6.66 KB
/
requirements.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/usr/bin/env bash
##--------------------------------------------------------------------
## Copyright (c) 2019 Dianomic Systems
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##--------------------------------------------------------------------
##
## Author: Ashish Jabble, Massimiliano Pinto, Vaibhav Singhal
##
set -e
# Upgrades curl to the version related to FogLAMP
curl_upgrade(){
if [ -d "${curl_tmp_path}" ]; then
rm -rf "${curl_tmp_path}"
fi
echo "Pulling curl from the FogLAMP curl repository ..."
cd /tmp/
curl -s -L -O "${curl_url}" && \
unzip -q "${curl_filename}"
cd "${curl_tmp_path}"
# curl in RHEL/CentOS is installed in /bin/curl
# but curl installs by default in /usr/local,
# so we select the proper target directories
echo "Building curl ..."
./buildconf && \
./configure --with-ssl --with-gssapi --includedir=/usr/include --libdir=/usr/lib64 --bindir=/usr/bin && \
make && \
make install
}
# Check if the curl version related to FogLAMP has been installed
curl_version_check () {
set +e
curl_version=$(curl -V | head -n 1)
curl_version_check=$(echo "${curl_version}" | grep -c "${curl_foglamp_version}")
if (( $curl_version_check >= 1 )); then
echo "curl version ${curl_foglamp_version} installed."
else
echo "WARNING: curl version ${curl_foglamp_version} not installed, current version :${curl_version}:"
fi
set -e
}
# Evaluates the current version of curl and upgrades it if needed
curl_upgrade_evaluates(){
set +e
curl_version=$(curl -V | head -n 1)
curl_version_check=$(echo "${curl_version}" | grep -c "${curl_rhel_version}")
set -e
# Evaluates if the curl is the default one and so it needs to be upgraded
if (( $curl_version_check >= 1 )); then
echo "curl version ${curl_rhel_version} detected, the standard RHEL/CentOS, upgrading to ${curl_foglamp_version}"
curl_upgrade
curl_version_check
else
echo "A curl version different from the default ${curl_rhel_version} detected, upgrade to a newer one if FogLAMP make fails."
echo "version detected :${curl_version}:"
# Evaluates if the installed version support Kerberos
curl_kerberos=$(curl -V | grep -ic "Kerberos")
curl_gssapi=$(curl -V | grep -ic "GSS-API")
if [[ $curl_kerberos == 0 || curl_gssapi == 0 ]]; then
echo "WARNING : the curl version detected doesn't support Kerberos."
fi
fi
}
# Variables for curl upgrade, if needed
curl_filename="curl-7.65.3"
curl_url="https://github.com/curl/curl/releases/download/curl-7_65_3/${curl_filename}.zip"
curl_tmp_path="/tmp/${curl_filename}"
curl_foglamp_version="7.65.3"
curl_rhel_version="7.29"
foglamp_location=`pwd`
os_name=`(grep -o '^NAME=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g')`
os_version=`(grep -o '^VERSION_ID=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g')`
echo "Platform is ${os_name}, Version: ${os_version}"
if [[ ( $os_name == *"Red Hat"* || $os_name == *"CentOS"* ) && $os_version == *"7"* ]]; then
if [[ $os_name == *"Red Hat"* ]]; then
yum-config-manager --enable 'Red Hat Software Collections RPMs for Red Hat Enterprise Linux 7 Server from RHUI'
yum install -y @development
else
yum groupinstall "Development tools" -y
yum install -y centos-release-scl
fi
yum install -y boost-devel
yum install -y glib2-devel
yum install -y rsyslog
yum install -y openssl-devel
yum install -y rh-python36
yum install -y rh-postgresql96
yum install -y rh-postgresql96-postgresql-devel
yum install -y wget
yum install -y zlib-devel
yum install -y git
yum install -y cmake
yum install -y libuuid-devel
# for Kerberos authentication
yum install -y krb5-workstation
yum install -y curl-devel
echo "source scl_source enable rh-python36" >> /home/${SUDO_USER}/.bashrc
service rsyslog start
# SQLite3 needs to be compiled on CentOS|RHEL
SQLITE_PKG_REPO_NAME="sqlite3-pkg"
if [ -d /tmp/${SQLITE_PKG_REPO_NAME} ]; then
rm -rf /tmp/${SQLITE_PKG_REPO_NAME}
fi
echo "Pulling SQLite3 from Dianomic ${SQLITE_PKG_REPO_NAME} repository ..."
cd /tmp/
git clone https://github.com/dianomic/${SQLITE_PKG_REPO_NAME}.git ${SQLITE_PKG_REPO_NAME}
cd ${SQLITE_PKG_REPO_NAME}
cd src
echo "Compiling SQLite3 static library for FogLAMP ..."
./configure --enable-shared=false --enable-static=true --enable-static-shell CFLAGS="-DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_LOAD_EXTENSION -DSQLITE_ENABLE_COLUMN_METADATA -fno-common -fPIC"
autoreconf -f -i
# Attempts a second execution of make if the first fails
set +e
make
exit_code=$?
if [[ $exit_code != 0 ]]; then
set -e
make
fi
cd $foglamp_location
set -e
# Upgrade curl if needed
curl_upgrade_evaluates
cd $foglamp_location
# To avoid to stop the execution for any internal error of scl_source
set +e
source scl_source enable rh-python36
set -e
#
# A gcc version newer than 4.9.0 is needed to properly use <regex>
# the installation of these packages will not overwrite the previous compiler
# the new one will be available using the command 'source scl_source enable devtoolset-7'
# the previous gcc will be enabled again after a log-off/log-in.
#
yum install -y yum-utils
yum-config-manager --enable rhel-server-rhscl-7-rpms
yum install -y devtoolset-7
# To avoid to stop the execution for any internal error of scl_source
set +e
source scl_source enable devtoolset-7
set -e
elif apt --version 2>/dev/null; then
# avoid interactive questions
DEBIAN_FRONTEND=noninteractive apt install -yq libssl-dev
apt install -y avahi-daemon curl
apt install -y cmake g++ make build-essential autoconf automake uuid-dev
apt install -y libtool libboost-dev libboost-system-dev libboost-thread-dev libpq-dev libz-dev
apt install -y python-dev python3-dev python3-pip
apt install -y sqlite3 libsqlite3-dev
apt install -y pkg-config
# for Kerberos authentication, avoid interactive questions
DEBIAN_FRONTEND=noninteractive apt install -yq krb5-user
DEBIAN_FRONTEND=noninteractive apt install -yq libcurl4-openssl-dev
apt install -y cpulimit
# apt install -y postgresql
else
echo "Requirements cannot be automatically installed, please refer README.rst to install requirements manually"
fi