blob: 87c9f9298e9da825440b67879c57bcfd5704173a [file] [log] [blame]
Andrew Gauld4e7e20e2017-08-22 13:33:45 +00001#!/bin/bash
2# ============LICENSE_START====================================================
3# org.onap.dcae
4# =============================================================================
5# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
6# =============================================================================
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
Andrew Gauldb34cbd02017-08-24 16:46:17 -040010#
Andrew Gauld4e7e20e2017-08-22 13:33:45 +000011# http://www.apache.org/licenses/LICENSE-2.0
Andrew Gauldb34cbd02017-08-24 16:46:17 -040012#
Andrew Gauld4e7e20e2017-08-22 13:33:45 +000013# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18# ============LICENSE_END======================================================
19
Jack Lucas775e0e72017-10-17 17:39:52 +000020CONSULVER=0.8.3
21CONSULNAME=consul_${CONSULVER}_linux_amd64
Andrew Gauld4e7e20e2017-08-22 13:33:45 +000022CB=/opt/consul/bin
23CD=/opt/consul/data
24CF=/opt/consul/config
25mkdir -p $CB $CD $CF
26cat >$CF/consul.json
27cd $CB
28wget https://releases.hashicorp.com/consul/${CONSULVER}/${CONSULNAME}.zip
29unzip ${CONSULNAME}.zip
30rm ${CONSULNAME}.zip
31mv consul ${CONSULNAME}
32ln -s ${CONSULNAME} consul
33cat <<EOF > /lib/systemd/system/consul.service
34[Unit]
35Description=Consul
36Requires=network-online.target
37After=network.target
38[Service]
39Type=simple
40ExecStart=/opt/consul/bin/consul agent -config-dir=/opt/consul/config
41ExecReload=/bin/kill -HUP \$MAINPID
42[Install]
43WantedBy=multi-user.target
44EOF
45systemctl enable consul
Andrew Gauldb34cbd02017-08-24 16:46:17 -040046systemctl start consul
Andrew Gauld4e7e20e2017-08-22 13:33:45 +000047until /opt/consul/bin/consul join "dcae-cnsl"
48do
49 echo Waiting to join Consul cluster
50 sleep 60
51done