-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall-mesos.sh
executable file
·240 lines (198 loc) · 8.63 KB
/
install-mesos.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
#!/usr/bin/env bash
#
# This file is part of the eskimo project referenced at www.eskimo.sh. The licensing information below apply just as
# well to this individual file than to the Eskimo Project as a whole.
#
# Copyright 2019 eskimo.sh / https://www.eskimo.sh - All rights reserved.
# Author : eskimo.sh / https://www.eskimo.sh
#
# Eskimo is available under a dual licensing model : commercial and GNU AGPL.
# If you did not acquire a commercial licence for Eskimo, you can still use it and consider it free software under the
# terms of the GNU Affero Public License. You can redistribute it and/or modify it under the terms of the GNU Affero
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
# any later version.
# Compliance to each and every aspect of the GNU Affero Public License is mandatory for users who did no acquire a
# commercial license.
#
# Eskimo is distributed as a free software under GNU AGPL in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero Public License for more details.
#
# You should have received a copy of the GNU Affero Public License along with Eskimo. If not,
# see <https://www.gnu.org/licenses/> or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA, 02110-1301 USA.
#
# You can be released from the requirements of the license by purchasing a commercial license. Buying such a
# commercial license is mandatory as soon as :
# - you develop activities involving Eskimo without disclosing the source code of your own product, software,
# platform, use cases or scripts.
# - you deploy eskimo as part of a commercial product, platform or software.
# For more information, please contact eskimo.sh at https://www.eskimo.sh
#
# The above copyright notice and this licensing notice shall be included in all copies or substantial portions of the
# Software.
#
export AMESOS_VERSION=1.7.2
function create_binary_wrapper(){
if [[ $1 == "" || $2 == "" ]]; then
echo "source and target have to be passed as argument of the create_kafka_wrapper function"
else
sudo touch $2
sudo chmod 777 $2
echo -e '#!/bin/bash' > $2
echo -e "" >> $2
echo -e "__tmp_saved_dir=`pwd`" >> $2
echo -e "function __tmp_returned_to_saved_dir() {" >> $2
echo -e ' cd $__tmp_saved_dir' >> $2
echo -e "}" >> $2
echo -e "trap __tmp_returned_to_saved_dir 15" >> $2
echo -e "trap __tmp_returned_to_saved_dir EXIT" >> $2
echo -e "" >> $2
echo -e "$1 \"\$@\"" >> $2
echo -e "" >> $2
echo -e "__tmp_returned_to_saved_dir" >> $2
sudo chmod 755 $2
fi
}
function fail_if_error(){
if [[ $1 != 0 ]]; then
echo " -> failed !!"
cat $2
exit $3
fi
}
function get_ip_address(){
export IP_ADDRESS="`cat /etc/network/interfaces | grep address | cut -d ' ' -f 8`"
}
echo "-- INSTALLING MESOS ------------------------------------------------------------"
if [ -z "$AMESOS_VERSION" ]; then
echo "Need to set AMESOS_VERSION environment variable before calling this script !"
exit 1
fi
saved_dir=`pwd`
function returned_to_saved_dir() {
cd $saved_dir
}
trap returned_to_saved_dir 15
trap returned_to_saved_dir EXIT
echo " - Changing to temp directory"
sudo rm -Rf /tmp/mesos_setup > /tmp/mesos_install_log 2>&1
mkdir -p /tmp/mesos_setup
if [[ -f "/etc/debian_version" ]]; then
mv niceideas_mesos-debian-$AMESOS_VERSION.tar.gz /tmp/mesos_setup/niceideas_mesos-$AMESOS_VERSION.tar.gz
else
mv niceideas_mesos-redhat-$AMESOS_VERSION.tar.gz /tmp/mesos_setup/niceideas_mesos-$AMESOS_VERSION.tar.gz
fi
cd /tmp/mesos_setup
echo " - Extracting mesos-$AMESOS_VERSION"
tar -zxf niceideas_mesos-$AMESOS_VERSION.tar.gz > /tmp/mesos_install_log 2>&1
fail_if_error $? "/tmp/mesos_install_log" -2
echo " - Removing any previous mesos installation"
sudo rm -Rf /usr/local/lib/mesos-$AMESOS_VERSION
sudo rm -Rf /usr/local/lib/mesos
echo " - Installing mesos"
sudo chown root.root -R mesos-$AMESOS_VERSION
sudo mv mesos-$AMESOS_VERSION /usr/local/lib
echo " - Symlinking /usr/local/lib/mesos-$AMESOS_VERSION to /usr/local/lib/mesos"
sudo ln -s /usr/local/lib/mesos-$AMESOS_VERSION /usr/local/lib/mesos
echo " - BUGFIXING mesos-tail "
sudo sed -i s/"master_state"/"state"/g /usr/local/lib/mesos-$AMESOS_VERSION/bin/mesos-tail
echo " - Simlinking mesos config to /usr/local/etc/mesos"
if [[ ! -f /usr/local/etc/mesos ]]; then
sudo ln -s /usr/local/lib/mesos/etc/mesos /usr/local/etc/mesos
fi
echo " - Simlinking mesos binaries to /usr/local/bin"
for i in `ls -1 /usr/local/lib/mesos/bin`; do
if [[ ! -f /usr/local/bin/$i ]]; then
sudo ln -s /usr/local/lib/mesos/bin/$i /usr/local/bin/$i
fi
done
echo " - Simlinking mesos system binaries to /usr/local/sbin"
for i in `ls -1 /usr/local/lib/mesos/sbin`; do
if [[ ! -f /usr/local/sbin/$i ]]; then
sudo ln -s /usr/local/lib/mesos/sbin/$i /usr/local/sbin/$i
fi
done
# installation tests
echo " - Basic environment setup (mesos cannot run without these variables)"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/:/usr/local/lib/mesos-$AMESOS_VERSION/lib
# etc profile
sudo bash -c "echo -e \"\n# Environment variables required for mesos\" >> /etc/profile"
sudo bash -c "echo -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/:/usr/local/lib/mesos-$AMESOS_VERSION/lib\" >> /etc/profile"
#sudo bash -c "echo -e \"export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/:/usr/local/lib/mesos-$AMESOS_VERSION/lib/python2.7/site-packages/\" >> /etc/profile"
# etc bash.bashrc
sudo bash -c "echo -e \"\n# Environment variables required for mesos\" >> /etc/bash.bashrc"
sudo bash -c "echo -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/:/usr/local/lib/mesos-$AMESOS_VERSION/lib\" >> /etc/bash.bashrc"
#sudo bash -c "echo -e \"export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/:/usr/local/lib/mesos-$AMESOS_VERSION/lib/python2.7/site-packages/\" >> /etc/bash.bashrc"
sudo ldconfig
sudo mkdir -p /var/lib/mesos
sudo chmod -R 777 /var/lib/mesos
echo " - Creating config mesos environment file"
sudo rm -Rf /usr/local/etc/mesos/mesos-env.sh
sudo bash -c "echo -e \"\n#Working configuration \" >> /usr/local/etc/mesos/mesos-env.sh"
sudo bash -c "echo \"export MESOS_log_dir=/var/log/mesos\" >> /usr/local/etc/mesos/mesos-env.sh"
sudo bash -c "echo -e \"\n#Specify a human readable name for the cluster \" >> /usr/local/etc/mesos/mesos-env.sh"
sudo bash -c "echo \"export MESOS_cluster=eskimo\" >> /usr/local/etc/mesos/mesos-env.sh"
echo " - Registering test cleaning traps"
export MESOS_MASTER_PROC_ID=-1
export MESOS_AGENT_PROC_ID=-1
function check_stop_mesos(){
if [[ $MESOS_MASTER_PROC_ID != -1 ]]; then
echo " - Stopping Mesos Master !!"
kill -15 $MESOS_MASTER_PROC_ID
fi
if [[ $MESOS_AGENT_PROC_ID != -1 ]]; then
echo " - Stopping Mesos Agent !! "
kill -15 $MESOS_AGENT_PROC_ID
fi
}
trap check_stop_mesos 15
trap check_stop_mesos EXIT
echo " - Starting Mesos Master"
sudo rm -Rf /tmp/mesos_tmp/master_work_dir/
sudo mkdir -p /tmp/mesos_tmp/master_work_dir/
sudo chmod -R 777 /tmp/mesos_tmp/master_work_dir/
/usr/local/lib/mesos-$AMESOS_VERSION/sbin/mesos-master \
--port=63050 \
--ip=127.0.0.1 \
--work_dir=/tmp/mesos_tmp/master_work_dir/ \
> /tmp/mesos_master_log 2>&1 &
export MESOS_MASTER_PROC_ID=$!
echo " - Checking Mesos master startup"
sleep 2
if [[ `ps -e | grep $MESOS_MASTER_PROC_ID` == "" ]]; then
echo " !! Failed to start Mesos Master !!"
cat /tmp/mesos_master_log
exit -8
fi
echo " - Starting Mesos Agent"
sudo rm -Rf /tmp/mesos_tmp/slave_work_dir/
sudo mkdir -p /tmp/mesos_tmp/slave_work_dir/
sudo chmod -R 777 /tmp/mesos_tmp/slave_work_dir/
/usr/local/lib/mesos-$AMESOS_VERSION/sbin/mesos-agent \
--port=63051 \
--master=127.0.0.1:63050 \
--no-systemd_enable_support \
--work_dir=/tmp/mesos_tmp/slave_work_dir/ \
> /tmp/mesos_agent_log 2>&1 &
export MESOS_AGENT_PROC_ID=$!
echo " - Checking Mesos Agent startup"
sleep 2
if [[ `ps -e | grep $MESOS_AGENT_PROC_ID` == "" ]]; then
echo " !! Failed to start Mesos Agent !!"
cat /tmp/mesos_agent_log
exit -9
fi
# Visit the Mesos web page.
#$ http://127.0.0.1:5050
echo " - Stopping Mesos Agent"
kill -15 $MESOS_AGENT_PROC_ID
export MESOS_AGENT_PROC_ID=-1
echo " - Stopping Mesos Master"
kill -15 $MESOS_MASTER_PROC_ID
export MESOS_MASTER_PROC_ID=-1
echo " - Cleaning build folder"
cd $saved_dir
sudo rm -Rf /tmp/mesos_setup > /tmp/mesos_install_log 2>&1
fail_if_error $? "/tmp/mesos_install_log" -10
returned_to_saved_dir