-
Notifications
You must be signed in to change notification settings - Fork 74
/
VagrantProvisionCentOS7.sh
executable file
·245 lines (195 loc) · 7.91 KB
/
VagrantProvisionCentOS7.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/usr/bin/env bash
set -e
###################################################
# VERY IMPORTANT: Set the $HOOT_HOME environment #
# variable prior to running this script if ~/hoot #
# isn't the correct location for HOOT_HOME #
###################################################
if [ -z "$HOOT_HOME" ]; then
HOOT_HOME=~/hoot
fi
echo HOOT_HOME: $HOOT_HOME
#################################################
# Common set of file versions
source $HOOT_HOME/VagrantProvisionVars.sh
VMUSER=`id -u -n`
echo USER: $VMUSER
VMGROUP=`groups | grep -o $VMUSER`
echo GROUP: $VMGROUP
export LANG=en_US.UTF-8
# Make sure that we are in ~ before trying to wget & install stuff
cd ~
source ~/.bash_profile
if [ "${ADDREPOS:-yes}" = "yes" ]; then
echo "Adding additional software repositories..."
# Ensure that CentOS Yum repository data is GPG-verified.
echo "### Configuring CentOS to verify repository metadata ###" >> CentOS_upgrade.txt
sudo yum-config-manager \
--save \
--setopt=base.repo_gpgcheck=1 \
--setopt=extras.repo_gpgcheck=1 \
--setopt=updates.repo_gpgcheck=1 &> /dev/null
# add EPEL repo for extra packages
echo "### Add epel repo ###" >> CentOS_upgrade.txt
sudo yum -y install epel-release >> CentOS_upgrade.txt 2>&1
# add GEOINT for spatial libraries and utilities.
echo "### Add geoint-deps repo ###" >> CentOS_upgrade.txt
sudo $HOOT_HOME/scripts/yum/geoint-repo.sh
# add Hoot repo for our pre-built dependencies.
echo "### Add Hoot repo ###" >> CentOS_upgrade.txt
sudo $HOOT_HOME/scripts/yum/hoot-repo.sh
# configure PGDG repository for PostgreSQL
echo "### Add pgdg repo ###" >> CentOS_upgrade.txt
sudo $HOOT_HOME/scripts/yum/pgdg-repo.sh $POSTGRESQL_VERSION
fi
# configure the devtoolset repository
echo "### Add devtoolset repo and postgresql ${POSTGRESQL_VERSION} libraries ###"
sudo yum install -y \
centos-release-scl postgresql${POSTGRESQL_VERSION}-libs >> CentOS_upgrade.txt 2>&1
sudo sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
sudo sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
sudo sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
if [ "${YUMUPDATE:-yes}" = "yes" ]; then
echo "Updating OS..."
echo "### Yum Upgrade ###" >> CentOS_upgrade.txt
echo "yum upgrade"
sudo yum -q -y upgrade # >> CentOS_upgrade.txt 2>&1
echo "yum worked"
fi
# Install hootenanny dependencies
$HOOT_HOME/VagrantProvisionCentOS7Deps.sh
# Fix missing qmake
if ! hash qmake >/dev/null 2>&1 ; then
if hash qmake-qt5 >/dev/null 2>&1 ; then
sudo alternatives --install /usr/bin/qmake qmake /usr/bin/qmake-qt5 500
else
echo "##### No qmake! #####"
fi
fi
cd $HOOT_HOME
echo "### Configuring environment..."
# Configure https alternative mirror for maven install, this can likely be removed once
# we are using maven 3.2.3 or higher
sudo /usr/bin/perl $HOOT_HOME/scripts/maven/SetMavenHttps.pl
if ! grep --quiet "export HOOT_HOME" ~/.bash_profile; then
echo "Adding hoot home to profile..."
echo "export HOOT_HOME=$HOOT_HOME" >> ~/.bash_profile
echo "export PATH=\$PATH:\$HOOT_HOME/bin" >> ~/.bash_profile
source ~/.bash_profile
fi
if ! grep --quiet "export JAVA_HOME" ~/.bash_profile; then
echo "Adding Java home to profile..."
echo "export JAVA_HOME=/usr/lib/jvm/java-$JDK_VERSION-openjdk" >> ~/.bash_profile
echo "export PATH=\$PATH:\$JAVA_HOME/bin" >> ~/.bash_profile
source ~/.bash_profile
else
sed -i '/^export JAVA_HOME=.*/c\export JAVA_HOME=\/usr\/lib\/jvm\/java-\$JDK_VERSION-openjdk' ~/.bash_profile
fi
# Update the GDAL_DATA folder in ~/.bash_profile
if ! grep --quiet GDAL_DATA ~/.bash_profile; then
echo "Adding GDAL data path to profile..."
echo "export GDAL_DATA=$(gdal-config --datadir)" >> ~/.bash_profile
source ~/.bash_profile
fi
# Make sure that we are in ~ before trying to wget & install stuff
cd ~
# Install Google Chrome and ChromeDriver.
$HOOT_HOME/scripts/chrome/driver-install.sh
# Configure PostgreSQL
echo "### Configuring PostgreSQL..."
$HOOT_HOME/scripts/database/ConfigurePostgresql.sh
echo "### Creating databases..."
$HOOT_HOME/scripts/database/SetupHootDb.sh
# Get ready to build Hoot
echo "SetupEnv.sh"
cd $HOOT_HOME
echo "$HOOT_HOME"
echo `pwd`
source ./SetupEnv.sh
if [ ! "$(ls -A hoot-ui-2x)" ]; then
echo "hoot-ui-2x is empty"
echo "init'ing and updating submodule"
git submodule init && git submodule update
fi
echo "### Installing Tomcat8..."
TOMCAT_HOME=/usr/share/tomcat8
# Install Tomcat 8
$HOOT_HOME/scripts/tomcat/centos7/tomcat8_install.sh
# Enable SSL for Tomcat
$HOOT_HOME/scripts/tomcat/configure_tomcat_ssl.sh
# Configure Tomcat for the user
if ! grep --quiet TOMCAT8_HOME ~/.bash_profile; then
echo "### Adding Tomcat to profile..."
echo "export TOMCAT8_HOME=$TOMCAT_HOME" >> ~/.bash_profile
source ~/.bash_profile
fi
if [ -f $HOOT_HOME/conf/LocalHoot.json ]; then
echo "Removing LocalHoot.json..."
rm -f $HOOT_HOME/conf/LocalHoot.json
fi
if [ -f $HOOT_HOME/hoot-services/src/main/resources/conf/local.conf ]; then
echo "Removing services local.conf..."
rm -f $HOOT_HOME/hoot-services/src/main/resources/conf/local.conf
fi
# Making sure we know where we are
cd ~
echo "### Installing node-export-server..."
sudo cp $HOOT_HOME/node-export-server/systemd/node-export.service /etc/systemd/system/node-export.service
sudo sed -i "s|SERVICE_USER|$VMUSER|g" /etc/systemd/system/node-export.service
sudo sed -i "s|HOOTENANNY_HOME|$HOOT_HOME|g" /etc/systemd/system/node-export.service
# Make sure all npm modules are installed
cd $HOOT_HOME/node-export-server
npm install --silent
# Clean up after the npm install
rm -rf ~/tmp
# Notify systemd that unit files have changed.
sudo systemctl daemon-reload
cd $HOOT_HOME
# Update marker file date now that dependency and config stuff has run
# The make command will exit and provide a warning to run 'vagrant provision'
# if the marker file is older than this file (VagrantProvision.sh)
touch Vagrant.marker
# Setup and clean out the directories that the UI uses
if [ ! -d "$HOOT_HOME/userfiles/ingest/processed" ]; then
mkdir -p $HOOT_HOME/userfiles/ingest/processed
fi
# wipe out all dirs. tmp and upload now reside under $HOOT_HOME/userfiles/
rm -rf $HOOT_HOME/upload
rm -rf $HOOT_HOME/tmp
if [ -d "$HOOT_HOME/data/reports" ]; then
echo "Moving contents of $HOOT_HOME/data/reports to $HOOT_HOME/userfiles/"
cp -R $HOOT_HOME/data/reports $HOOT_HOME/userfiles/
rm -rf $HOOT_HOME/data/reports
fi
if [ -d "$HOOT_HOME/customscript" ]; then
echo "Moving contents of $HOOT_HOME/customscript to $HOOT_HOME/userfiles/"
cp -R $HOOT_HOME/customscript $HOOT_HOME/userfiles/
rm -rf $HOOT_HOME/customscript
fi
if [ -d "$HOOT_HOME/ingest" ]; then
echo "Moving contents of $HOOT_HOME/ingest to $HOOT_HOME/userfiles/"
cp -R $HOOT_HOME/ingest $HOOT_HOME/userfiles/
rm -rf $HOOT_HOME/ingest
fi
# Always start with a clean $HOOT_HOME/userfiles/tmp
rm -rf $HOOT_HOME/userfiles/tmp
# This is defensive!
# We do this so that Tomcat doesn't. If it does, it screws the permissions up
mkdir -p $HOOT_HOME/userfiles/tmp
# Update the gcc location to devtoolset
if ! grep --quiet "devtoolset-$DEVTOOLSET_VERSION" ~/.bash_profile; then
echo "Adding devtoolset-$DEVTOOLSET_VERSION to profile..."
# Devtoolset <= 8 has a sudo issue, fix it here
if [ $(($DEVTOOLSET_VERSION)) -le 8 ]; then
sudo chmod -x /opt/rh/devtoolset-$DEVTOOLSET_VERSION/root/usr/bin/sudo
fi
# Enable devtoolset
echo "source /opt/rh/devtoolset-$DEVTOOLSET_VERSION/enable" >> ~/.bash_profile
fi
# OK, this is seriously UGLY but it fixes an NFS problem
#chmod -R 777 $HOOT_HOME/userfiles
# This is very ugly.
# If we don't have access to the directory where HOOT_HOME is, Tomcat chokes
#chmod go+rx ~
##########################################