blob: 71a5fea86d99a87deaba556c14c0a1906d8ab078 [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 {
Victor Morales56cd8df2018-02-12 16:51:40 -080027 build_docker_image ${src_folders[sdc]}/sdc-docker-base
Victor Morales472a3062018-02-02 08:26:50 -080028 build_docker_image ${src_folders[sdc]}/utils/webseal-simulator docker
Victor Moralese7467002017-08-30 14:50:43 -050029 if [[ "$build_image" == "True" ]]; then
Victor Morales472a3062018-02-02 08:26:50 -080030 compile_src ${src_folders[sdc]}
31 for project in catalog-fe test-apis-ci; do
32 compile_src ${src_folders[sdc]}/$project
Victor Morales6a919972017-09-28 18:29:54 -070033 done
Victor Morales472a3062018-02-02 08:26:50 -080034 build_docker_image ${src_folders[sdc]}/sdc-os-chef docker
35 else
36 for image in elasticsearch init-elasticsearch cassandra kibana backend frontend sanity; do
37 pull_onap_image sdc-$image &
38 done
39 wait_docker_pull
Victor Moralese7467002017-08-30 14:50:43 -050040 fi
41}
42
Victor Morales89ce3212017-06-16 18:32:48 -050043# install_sdc() - Function that pull templates and executes
44function install_sdc {
Victor Morales89ce3212017-06-16 18:32:48 -050045 local ENV_NAME=$dmaap_topic
46 local MR_IP_ADDR='10.0.11.1'
Victor Moralesdd074802017-07-26 16:06:35 -050047
Victor Morales56cd8df2018-02-12 16:51:40 -080048 pushd ${src_folders[sdc]}/utils/webseal-simulator
49 bash scripts/simulator_docker_run.sh
50 popd
51
Victor Moralese7467002017-08-30 14:50:43 -050052 _init_data_folders
Victor Morales472a3062018-02-02 08:26:50 -080053
Victor Moralesf6dbe282018-03-05 10:58:15 -080054 cp ${src_folders[sdc]}/sdc-os-chef/scripts/{docker_run.sh,docker_health.sh,docker_login.sh,docker_clean.sh,simulator_docker_run.sh} /data/scripts
Victor Morales472a3062018-02-02 08:26:50 -080055 chmod +x /data/scripts/*.sh
Victor Morales6a919972017-09-28 18:29:54 -070056
Victor Moralesf6dbe282018-03-05 10:58:15 -080057 cat ${src_folders[sdc]}/sdc-os-chef/environments/Template.json | sed "s/yyy/"$IP_ADDRESS"/g" > /data/environments/$ENV_NAME.json
Victor Morales89ce3212017-06-16 18:32:48 -050058 sed -i "s/xxx/"$ENV_NAME"/g" /data/environments/$ENV_NAME.json
59 sed -i "s/\"ueb_url_list\":.*/\"ueb_url_list\": \""$MR_IP_ADDR","$MR_IP_ADDR"\",/g" /data/environments/$ENV_NAME.json
60 sed -i "s/\"fqdn\":.*/\"fqdn\": [\""$MR_IP_ADDR"\", \""$MR_IP_ADDR"\"]/g" /data/environments/$ENV_NAME.json
61
Idan Amit0a295552017-08-17 17:03:59 +030062 install_docker
Victor Moralesa44489e2017-10-05 08:18:01 -070063 if [[ "$skip_get_images" == "False" ]]; then
Victor Morales472a3062018-02-02 08:26:50 -080064 bash /data/scripts/docker_run.sh -e $ENV_NAME -l
Victor Moralesa44489e2017-10-05 08:18:01 -070065 else
66 bash /data/scripts/docker_run.sh -e $ENV_NAME -r $docker_version -p $(echo $nexus_docker_repo | cut -d':' -f2)
67 fi
Victor Moralesf6dbe282018-03-05 10:58:15 -080068 install_chefdk
Victor Morales89ce3212017-06-16 18:32:48 -050069}
70
Idan Amitbf1e7f02017-08-20 16:05:46 +030071# init_sdc() - Function that initialize SDC services
72function init_sdc {
Victor Moralesfa9eb9c2017-12-18 09:56:13 -080073 mount_external_partition sdb /data/
Idan Amit1690e082017-08-20 08:58:14 +030074 if [[ "$clone_repo" == "True" ]]; then
Victor Moralesf1f1ba52017-11-20 16:38:28 -080075 clone_repos "sdc"
Idan Amit1690e082017-08-20 08:58:14 +030076 if [[ "$compile_repo" == "True" ]]; then
Victor Moralesf1f1ba52017-11-20 16:38:28 -080077 compile_repos "sdc"
Idan Amit1690e082017-08-20 08:58:14 +030078 fi
79 fi
Victor Morales6a919972017-09-28 18:29:54 -070080
81 if [[ "$skip_get_images" == "False" ]]; then
82 get_sdc_images
Victor Moralesa44489e2017-10-05 08:18:01 -070083 fi
84 if [[ "$skip_install" == "False" ]]; then
85 install_sdc
Victor Morales6a919972017-09-28 18:29:54 -070086 fi
Victor Moralese7467002017-08-30 14:50:43 -050087 _setup_docker_aliases
Victor Morales89ce3212017-06-16 18:32:48 -050088}