preserve newline at end of templates
[yaml_builds.git] / tools / single_step_deploy.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.          #
4 #                                                                            #
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may    #
6 # not use this file except in compliance with the License.                   #
7 #                                                                            #
8 # You may obtain a copy of the License at                                    #
9 #       http://www.apache.org/licenses/LICENSE-2.0                           #
10 #                                                                            #
11 # Unless required by applicable law or agreed to in writing, software        #
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
14 # See the License for the specific language governing permissions and        #
15 # limitations under the License.                                             #
16 ##############################################################################
17
18 set -x
19
20 if [ -z "$1" ]
21 then
22   echo "Please pass site name as command line argument"
23   exit -2
24 else
25   export SITE=${SITE:-$1}
26   echo "SITE=$SITE"
27 fi
28
29 source $(dirname $0)/setenv.sh
30 TIMESTAMP=$(date +"%Y%m%d%H%M")
31 echo "TIMESTAMP=$TIMESTAMP"
32
33 echo "Validating the setup and generating the tar file"
34 mkdir -p /var/log/yaml_builds
35 bash $YAML_BUILDS/tools/1prom-gen.sh $SITE > /var/log/yaml_builds/1prom-gen-$TIMESTAMP.log 2>&1
36 if [ $? -ne 0 ]
37 then
38   echo "Error:Could not generate tar file. So stopping here"
39   exit 1 
40 fi
41
42 echo "Bringing up the genesis node"
43 bash $YAML_BUILDS/tools/2genesis.sh $SITE > /var/log/yaml_builds/2genesis-$TIMESTAMP.log 2>&1
44 if [ $? -ne 0 ]
45 then
46   echo "Error:Could not bringup the genesis nodes. So stopping here"
47   exit 2
48 fi
49
50 echo "Deploying the site"
51 bash $YAML_BUILDS/tools/3deploy_site.sh $SITE > /var/log/yaml_builds/3deploy-$TIMESTAMP.log 2>&1
52 if [ $? -ne 0 ]
53 then
54   echo "Error:Could not deploy the site."
55   exit 3
56 fi
57 echo "We are done."