blob: fee583d79c4dc10b55409cc2478e85732822f1ff [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
Victor Moralesdd074802017-07-26 16:06:35 -05003source /var/onap/functions
Victor Moralesdd074802017-07-26 16:06:35 -05004
Victor Moralese7467002017-08-30 14:50:43 -05005# _init_data_folders() - Function that initialize the data folders
6function _init_data_folders {
Victor Morales89ce3212017-06-16 18:32:48 -05007 mkdir -p /data/environments
8 mkdir -p /data/scripts
9 mkdir -p /data/logs/BE
10 mkdir -p /data/logs/FE
11 chmod 777 /data
Idan Amitc46e98f2017-08-21 17:04:10 +030012 chmod 777 /data/logs
Victor Morales89ce3212017-06-16 18:32:48 -050013}
14
Victor Moralese7467002017-08-30 14:50:43 -050015# _setup_docker_aliases() - Function that setups the aliases required by sdc scripts
16function _setup_docker_aliases {
Victor Morales89ce3212017-06-16 18:32:48 -050017 cat <<EOL > /root/.bash_aliases
18alias dcls='/data/scripts/docker_clean.sh \$1'
19alias dlog='/data/scripts/docker_login.sh \$1'
Idan Amit8e393c32017-09-27 17:55:52 +030020alias drun='/data/scripts/docker_run.sh'
Victor Morales89ce3212017-06-16 18:32:48 -050021alias health='/data/scripts/docker_health.sh'
22EOL
23}
24
Victor Moralese7467002017-08-30 14:50:43 -050025# get_sdc_images() - Function that retrieves the SDC docker images
26function get_sdc_images {
27 if [[ "$build_image" == "True" ]]; then
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070028 build_docker_image $sdc_src_folder/sdc-docker-base
Victor Moralese7467002017-08-30 14:50:43 -050029 else
Victor Morales6a919972017-09-28 18:29:54 -070030 for image in backend frontend elasticsearch kibana cassandra sanity; do
31 pull_openecomp_image openecomp/sdc-$image
32 done
Victor Moralese7467002017-08-30 14:50:43 -050033 fi
34}
35
Victor Morales89ce3212017-06-16 18:32:48 -050036# install_sdc() - Function that pull templates and executes
37function install_sdc {
Victor Morales89ce3212017-06-16 18:32:48 -050038 local ENV_NAME=$dmaap_topic
39 local MR_IP_ADDR='10.0.11.1'
Victor Moralesdd074802017-07-26 16:06:35 -050040
Victor Moralese7467002017-08-30 14:50:43 -050041 _init_data_folders
Victor Morales6a919972017-09-28 18:29:54 -070042 cp $sdc_src_folder/sdc-os-chef/environments/Template.json /data/environments
43 cp $sdc_src_folder/sdc-os-chef/scripts/docker_run.sh /data/scripts
44 cp $sdc_src_folder/sdc-os-chef/scripts/docker_health.sh /data/scripts
45 cp $sdc_src_folder/sdc-os-chef/scripts/docker_login.sh /data/scripts
46 cp $sdc_src_folder/sdc-os-chef/scripts/docker_clean.sh /data/scripts
47 chmod +x /data/scripts/docker_run.sh
48 chmod +x /data/scripts/docker_health.sh
49 chmod +x /data/scripts/docker_login.sh
50 chmod +x /data/scripts/docker_clean.sh
51
Victor Morales89ce3212017-06-16 18:32:48 -050052 cat /data/environments/Template.json | sed "s/yyy/"$IP_ADDRESS"/g" > /data/environments/$ENV_NAME.json
53 sed -i "s/xxx/"$ENV_NAME"/g" /data/environments/$ENV_NAME.json
54 sed -i "s/\"ueb_url_list\":.*/\"ueb_url_list\": \""$MR_IP_ADDR","$MR_IP_ADDR"\",/g" /data/environments/$ENV_NAME.json
55 sed -i "s/\"fqdn\":.*/\"fqdn\": [\""$MR_IP_ADDR"\", \""$MR_IP_ADDR"\"]/g" /data/environments/$ENV_NAME.json
56
Idan Amit0a295552017-08-17 17:03:59 +030057 install_docker
Victor Moralesa44489e2017-10-05 08:18:01 -070058 if [[ "$skip_get_images" == "False" ]]; then
59 bash /data/scripts/docker_run.sh -e $ENV_NAME -l
60 else
61 bash /data/scripts/docker_run.sh -e $ENV_NAME -r $docker_version -p $(echo $nexus_docker_repo | cut -d':' -f2)
62 fi
Victor Morales89ce3212017-06-16 18:32:48 -050063}
64
Idan Amitbf1e7f02017-08-20 16:05:46 +030065# init_sdc() - Function that initialize SDC services
66function init_sdc {
Victor Moralesfa9eb9c2017-12-18 09:56:13 -080067 mount_external_partition sdb /data/
Idan Amit1690e082017-08-20 08:58:14 +030068 if [[ "$clone_repo" == "True" ]]; then
Victor Moralesf1f1ba52017-11-20 16:38:28 -080069 clone_repos "sdc"
Idan Amit1690e082017-08-20 08:58:14 +030070 if [[ "$compile_repo" == "True" ]]; then
Victor Moralesf1f1ba52017-11-20 16:38:28 -080071 compile_repos "sdc"
Idan Amit1690e082017-08-20 08:58:14 +030072 fi
73 fi
Victor Morales6a919972017-09-28 18:29:54 -070074
75 if [[ "$skip_get_images" == "False" ]]; then
76 get_sdc_images
Victor Moralesa44489e2017-10-05 08:18:01 -070077 fi
78 if [[ "$skip_install" == "False" ]]; then
79 install_sdc
Victor Morales6a919972017-09-28 18:29:54 -070080 fi
Victor Moralese7467002017-08-30 14:50:43 -050081 _setup_docker_aliases
Victor Morales89ce3212017-06-16 18:32:48 -050082}