Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 3 | source /var/onap/functions |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 4 | |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 5 | # _init_data_folders() - Function that initialize the data folders |
| 6 | function _init_data_folders { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 7 | 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 Amit | c46e98f | 2017-08-21 17:04:10 +0300 | [diff] [blame] | 12 | chmod 777 /data/logs |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 13 | } |
| 14 | |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 15 | # _setup_docker_aliases() - Function that setups the aliases required by sdc scripts |
| 16 | function _setup_docker_aliases { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 17 | cat <<EOL > /root/.bash_aliases |
| 18 | alias dcls='/data/scripts/docker_clean.sh \$1' |
| 19 | alias dlog='/data/scripts/docker_login.sh \$1' |
Idan Amit | 8e393c3 | 2017-09-27 17:55:52 +0300 | [diff] [blame] | 20 | alias drun='/data/scripts/docker_run.sh' |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 21 | alias health='/data/scripts/docker_health.sh' |
| 22 | EOL |
| 23 | } |
| 24 | |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 25 | # get_sdc_images() - Function that retrieves the SDC docker images |
| 26 | function get_sdc_images { |
Victor Morales | 56cd8df | 2018-02-12 16:51:40 -0800 | [diff] [blame] | 27 | build_docker_image ${src_folders[sdc]}/sdc-docker-base |
Victor Morales | 472a306 | 2018-02-02 08:26:50 -0800 | [diff] [blame] | 28 | build_docker_image ${src_folders[sdc]}/utils/webseal-simulator docker |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 29 | if [[ "$build_image" == "True" ]]; then |
Victor Morales | 472a306 | 2018-02-02 08:26:50 -0800 | [diff] [blame] | 30 | compile_src ${src_folders[sdc]} |
| 31 | for project in catalog-fe test-apis-ci; do |
| 32 | compile_src ${src_folders[sdc]}/$project |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 33 | done |
Victor Morales | 472a306 | 2018-02-02 08:26:50 -0800 | [diff] [blame] | 34 | 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 Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 40 | fi |
| 41 | } |
| 42 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 43 | # install_sdc() - Function that pull templates and executes |
| 44 | function install_sdc { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 45 | local ENV_NAME=$dmaap_topic |
| 46 | local MR_IP_ADDR='10.0.11.1' |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 47 | |
Victor Morales | 56cd8df | 2018-02-12 16:51:40 -0800 | [diff] [blame] | 48 | pushd ${src_folders[sdc]}/utils/webseal-simulator |
| 49 | bash scripts/simulator_docker_run.sh |
| 50 | popd |
| 51 | |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 52 | _init_data_folders |
Victor Morales | 472a306 | 2018-02-02 08:26:50 -0800 | [diff] [blame] | 53 | |
Victor Morales | f6dbe28 | 2018-03-05 10:58:15 -0800 | [diff] [blame] | 54 | 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 Morales | 472a306 | 2018-02-02 08:26:50 -0800 | [diff] [blame] | 55 | chmod +x /data/scripts/*.sh |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 56 | |
Victor Morales | f6dbe28 | 2018-03-05 10:58:15 -0800 | [diff] [blame] | 57 | cat ${src_folders[sdc]}/sdc-os-chef/environments/Template.json | sed "s/yyy/"$IP_ADDRESS"/g" > /data/environments/$ENV_NAME.json |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 58 | 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 Amit | 0a29555 | 2017-08-17 17:03:59 +0300 | [diff] [blame] | 62 | install_docker |
Victor Morales | a44489e | 2017-10-05 08:18:01 -0700 | [diff] [blame] | 63 | if [[ "$skip_get_images" == "False" ]]; then |
Victor Morales | 472a306 | 2018-02-02 08:26:50 -0800 | [diff] [blame] | 64 | bash /data/scripts/docker_run.sh -e $ENV_NAME -l |
Victor Morales | a44489e | 2017-10-05 08:18:01 -0700 | [diff] [blame] | 65 | 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 Morales | f6dbe28 | 2018-03-05 10:58:15 -0800 | [diff] [blame] | 68 | install_chefdk |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 69 | } |
| 70 | |
Idan Amit | bf1e7f0 | 2017-08-20 16:05:46 +0300 | [diff] [blame] | 71 | # init_sdc() - Function that initialize SDC services |
| 72 | function init_sdc { |
Victor Morales | fa9eb9c | 2017-12-18 09:56:13 -0800 | [diff] [blame] | 73 | mount_external_partition sdb /data/ |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 74 | if [[ "$clone_repo" == "True" ]]; then |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 75 | clone_repos "sdc" |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 76 | if [[ "$compile_repo" == "True" ]]; then |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 77 | compile_repos "sdc" |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 78 | fi |
| 79 | fi |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 80 | |
| 81 | if [[ "$skip_get_images" == "False" ]]; then |
| 82 | get_sdc_images |
Victor Morales | a44489e | 2017-10-05 08:18:01 -0700 | [diff] [blame] | 83 | fi |
| 84 | if [[ "$skip_install" == "False" ]]; then |
| 85 | install_sdc |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 86 | fi |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 87 | _setup_docker_aliases |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 88 | } |