This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
provision_experiment_environment.sh
executable file
·173 lines (141 loc) · 6.16 KB
/
provision_experiment_environment.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
#!/usr/bin/env bash
# Copyright (c) 2017 Intel Corporation
#
# 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.
set -x -e -o pipefail
if [ "$USER" != "root" ]; then
echo "This script needs to be run with root privileges"
exit 1
fi
if [ "$SWAN_USER" == "" ]; then
echo "You need to set SWAN_USER environmental variable"
exit 1
fi
if [ "$HOME_DIR" == "" ]; then
echo "You need to set HOME_DIR environmental variable"
exit 1
fi
SWAN_BIN=/opt/swan/bin
SWAN_VERSION="v0.15"
SWAN_SERVICES_DIR=${SWAN_SERVICES_DIR:-"/vagrant"}
K8S_VERSION="v1.7.4"
SNAP_VERSION="2.0.0"
ETCD_VERSION="3.2.18"
DOCKER_VERSION="17.06.1.ce-1.el7.centos"
# The offical Docker repository is not very, stable apparently.
# See https://github.com/moby/moby/issues/33930#issuecomment-312782998 for explanation.
DOCKER_INSTALL_OPTS="-y -q --setopt=obsoletes=0"
SNAP_PLUGIN_COLLECTOR_DOCKER_VERSION=8
SNAP_PLUGIN_COLLECTOR_RDT_VERSION=1
SNAP_PLUGIN_COLLECTOR_USE_VERSION=1
SNAP_PLUGIN_PUBLISHER_CASSANDRA_VERSION=7
SNAP_PLUGIN_PUBLISHER_FILE_VERSION=2
echo "------------------------ Install OS Packages (`date`)"
yum makecache fast -y -q
yum update -y -q
yum install -y -q epel-release # Enables EPEL repo
yum install -y -q \
wget \
etcd-${ETCD_VERSION} \
python-pip \
python-devel \
libcgroup-tools \
boost \
glog \
protobuf \
opencv \
hdf5 \
leveldb \
lmdb \
opencv \
libgomp \
libevent \
git \
zeromq \
cppzmq-devel \
gengetopt \
libevent-devel \
scons \
gcc-c++
echo "------------------------ Prepare services (`date`)"
function daemonStatus() {
echo "$1 service status: $(systemctl show -p SubState $1 | cut -d'=' -f2)"
}
echo "Reload services"
systemctl daemon-reload
echo "----------------------------- Install Docker (`date`)"
# https://docs.docker.com/engine/installation/linux/centos/#install-using-the-repository
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum makecache fast -y -q
yum install ${DOCKER_INSTALL_OPTS} docker-ce-${DOCKER_VERSION}
echo "Restart docker"
systemctl enable docker
systemctl start docker
docker run hello-world
gpasswd -a $SWAN_USER docker
daemonStatus docker
echo "----------------------------- Create Swan Installation Directory (`date`)"
mkdir -p ${SWAN_BIN}
echo "----------------------------- Install Swan Release Package(`date`)"
wget --no-verbose https://github.com/intelsdi-x/swan/releases/download/${SWAN_VERSION}/swan.tar.gz -O /tmp/swan.tar.gz
tar -xzf /tmp/swan.tar.gz -C ${SWAN_BIN}
echo "----------------------------- Pulling docker image (`date`)"
docker pull intelsdi/swan
echo "----------------------------- Retrieve binares from Docker container (`date`)"
docker run --rm -v /opt:/output intelsdi/swan cp -R /opt/swan /output
echo "----------------------------- Install Kubernetes (`date`)"
wget --no-verbose https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/hyperkube -O ${SWAN_BIN}/hyperkube
chmod +x ${SWAN_BIN}/hyperkube
echo "----------------------------- Install etcd (`date`)"
systemctl enable etcd
systemctl restart etcd
daemonStatus etcd
echo "----------------------------- Install Cassandra (`date`)"
cp ${SWAN_SERVICES_DIR}/cassandra/cassandra.service /etc/systemd/system
mkdir -p /var/data/cassandra
chcon -Rt svirt_sandbox_file_t /var/data/cassandra # SELinux policy
systemctl enable cassandra
echo "Restart Cassandra"
systemctl restart cassandra
daemonStatus cassandra
echo "----------------------------- Install InfluxDB (`date`)"
cp ${SWAN_SERVICES_DIR}/influxdb/influxdb.service /etc/systemd/system
mkdir -p /var/lib/influxdb
chcon -Rt svirt_sandbox_file_t /var/lib/influxdb # SELinux policy
systemctl enable influxdb
echo "Restart InfluxDB"
systemctl restart influxdb
daemonStatus influxdb
echo "----------------------------- Install Snap telemetry (`date`)"
curl -s https://packagecloud.io/install/repositories/intelsdi-x/snap/script.rpm.sh | bash
yum list -q --show-duplicates snap-telemetry
yum install -y -q snap-telemetry-${SNAP_VERSION}
systemctl enable snap-telemetry
systemctl start snap-telemetry
daemonStatus snap-telemetry
ln -sf /opt/snap/bin/* /usr/bin/
ln -sf /opt/snap/sbin/* /usr/sbin/
echo "----------------------------- Install external Snap plugins (`date`)"
wget --no-verbose https://github.com/intelsdi-x/snap-plugin-collector-docker/releases/download/${SNAP_PLUGIN_COLLECTOR_DOCKER_VERSION}/snap-plugin-collector-docker_linux_x86_64 -O ${SWAN_BIN}/snap-plugin-collector-docker
wget --no-verbose https://github.com/intelsdi-x/snap-plugin-collector-rdt/releases/download/${SNAP_PLUGIN_COLLECTOR_RDT_VERSION}/snap-plugin-collector-rdt.tar.gz -O ${SWAN_BIN}/snap-plugin-collector-rdt.tar.gz
tar -xzf ${SWAN_BIN}/snap-plugin-collector-rdt.tar.gz -C ${SWAN_BIN}
wget --no-verbose https://github.com/intelsdi-x/snap-plugin-collector-use/releases/download/${SNAP_PLUGIN_COLLECTOR_USE_VERSION}/snap-plugin-collector-use_linux_x86_64 -O ${SWAN_BIN}/snap-plugin-collector-use
wget --no-verbose https://github.com/intelsdi-x/snap-plugin-publisher-cassandra/releases/download/${SNAP_PLUGIN_PUBLISHER_CASSANDRA_VERSION}/snap-plugin-publisher-cassandra_linux_x86_64 -O ${SWAN_BIN}/snap-plugin-publisher-cassandra
wget --no-verbose https://github.com/intelsdi-x/snap-plugin-publisher-file/releases/download/${SNAP_PLUGIN_PUBLISHER_FILE_VERSION}/snap-plugin-publisher-file_linux_x86_64 -O ${SWAN_BIN}/snap-plugin-publisher-file
echo "---------------------------- Post install (`date`)"
chmod +x -R ${SWAN_BIN}
chown -R $SWAN_USER:$SWAN_USER $HOME_DIR
chown -R $SWAN_USER:$SWAN_USER /opt/swan
chmod -R +x ${SWAN_BIN}/*
ln -svf ${SWAN_BIN}/* /usr/bin/
echo "---------------------------- Provisioning experiment environment done (`date`)"