blob: 9d64d57da7949e714bdf156307a0a3aa328216bf [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
Victor Moralesdd074802017-07-26 16:06:35 -05005source /var/onap/functions
6source /var/onap/asserts
7
8src_folder=$git_src_folder/sdc
9
Victor Morales89ce3212017-06-16 18:32:48 -050010# mount_external_partition() - Create partition and mount the external volume
11function mount_external_partition {
Idan Amitbf1e7f02017-08-20 16:05:46 +030012 cat <<EOL > /tmp/sdc_ext_volume_partitions.txt
Victor Morales89ce3212017-06-16 18:32:48 -050013# partition table of /dev/sdb
14unit: sectors
15
16/dev/sdb1 : start= 2048, size=209713152, Id=83
17/dev/sdb2 : start= 0, size= 0, Id= 0
18/dev/sdb3 : start= 0, size= 0, Id= 0
19/dev/sdb4 : start= 0, size= 0, Id= 0
20EOL
Idan Amitbf1e7f02017-08-20 16:05:46 +030021 sfdisk --force /dev/sdb < /tmp/sdc_ext_volume_partitions.txt
Victor Morales89ce3212017-06-16 18:32:48 -050022 mkfs -t ext4 /dev/sdb1
23 mkdir -p /data
24 mount /dev/sdb1 /data
25 echo "/dev/sdb1 /data ext4 errors=remount-ro,noatime,barrier=0 0 1" >> /etc/fstab
26}
27
28# init_data_folders() - Function that initialize the data folders
29function init_data_folders {
30 mkdir -p /data/environments
31 mkdir -p /data/scripts
32 mkdir -p /data/logs/BE
33 mkdir -p /data/logs/FE
34 chmod 777 /data
Idan Amitc46e98f2017-08-21 17:04:10 +030035 chmod 777 /data/logs
Victor Morales89ce3212017-06-16 18:32:48 -050036}
37
38# setup_docker_aliases() - Function that setups the aliases required by sdc scripts
39function setup_docker_aliases {
40 cat <<EOL > /root/.bash_aliases
41alias dcls='/data/scripts/docker_clean.sh \$1'
42alias dlog='/data/scripts/docker_login.sh \$1'
43alias rund='/data/scripts/docker_run.sh'
44alias health='/data/scripts/docker_health.sh'
45EOL
46}
47
Victor Moralesdd074802017-07-26 16:06:35 -050048# clone_all_sdc_repos() - Function that clones SDC source repo.
49function clone_all_sdc_repos {
50 clone_repo sdc $src_folder
51
52 for dirc in sdc-os-chef jtosca sdc-distribution-client sdc-titan-cassandra sdc-tosca sdc_common ; do
53 clone_repo sdc/$dirc $src_folder/$dirc
54 done
55}
56
57# compile_all_sdc_repos() - Function that compiles SDC source repo.
58function compile_all_sdc_repos {
59 local src_folder=/opt/sdc
60 clone_repo sdc $src_folder
61
62 for dirc in jtosca sdc-distribution-client sdc-titan-cassandra sdc-tosca sdc_common ; do
63 compile_src $src_folder/$dirc
64 done
65}
66
Victor Morales89ce3212017-06-16 18:32:48 -050067# install_sdc() - Function that pull templates and executes
68function install_sdc {
Victor Morales89ce3212017-06-16 18:32:48 -050069 local ENV_NAME=$dmaap_topic
70 local MR_IP_ADDR='10.0.11.1'
71 local RELEASE=$docker_version
72 NEXUS_DOCKER_PORT=$(echo $nexus_docker_repo | cut -d':' -f2)
Victor Moralesdd074802017-07-26 16:06:35 -050073
Victor Morales89ce3212017-06-16 18:32:48 -050074 if [[ "$build_image" == "True" ]]; then
75 compile_src $src_folder
Victor Moralesdd074802017-07-26 16:06:35 -050076 build_docker_image $src_folder/sdc-os-chef docker
77 for image in backend frontend elasticsearch kibana cassandra sanity; do
78 asserts_image openecomp/sdc-$image
79 done
Victor Morales89ce3212017-06-16 18:32:48 -050080 fi
81 cp $src_folder/sdc-os-chef/environments/Template.json /data/environments
82 cp $src_folder/sdc-os-chef/scripts/docker_run.sh /data/scripts
83 cp $src_folder/sdc-os-chef/scripts/docker_health.sh /data/scripts
84 chmod +x /data/scripts/docker_run.sh
85 chmod +x /data/scripts/docker_health.sh
86
87 cat /data/environments/Template.json | sed "s/yyy/"$IP_ADDRESS"/g" > /data/environments/$ENV_NAME.json
88 sed -i "s/xxx/"$ENV_NAME"/g" /data/environments/$ENV_NAME.json
89 sed -i "s/\"ueb_url_list\":.*/\"ueb_url_list\": \""$MR_IP_ADDR","$MR_IP_ADDR"\",/g" /data/environments/$ENV_NAME.json
90 sed -i "s/\"fqdn\":.*/\"fqdn\": [\""$MR_IP_ADDR"\", \""$MR_IP_ADDR"\"]/g" /data/environments/$ENV_NAME.json
91
Idan Amit0a295552017-08-17 17:03:59 +030092 install_docker
93 if [[ "$pull_docker_image" == "True" ]]; then
94 docker_openecomp_login
95 bash /data/scripts/docker_run.sh -e $ENV_NAME -r $RELEASE -p $NEXUS_DOCKER_PORT
96 fi
Victor Morales89ce3212017-06-16 18:32:48 -050097}
98
Idan Amitbf1e7f02017-08-20 16:05:46 +030099# init_sdc() - Function that initialize SDC services
100function init_sdc {
Victor Morales89ce3212017-06-16 18:32:48 -0500101 mount_external_partition
102 init_data_folders
103 setup_docker_aliases
Idan Amit1690e082017-08-20 08:58:14 +0300104 if [[ "$clone_repo" == "True" ]]; then
105 clone_all_sdc_repos
106 if [[ "$compile_repo" == "True" ]]; then
107 compile_all_sdc_repos
108 fi
109 fi
Victor Morales89ce3212017-06-16 18:32:48 -0500110 install_sdc
111}