#!/bin/bash source /var/onap/functions # _init_data_folders() - Function that initialize the data folders function _init_data_folders { mkdir -p /data/environments mkdir -p /data/scripts mkdir -p /data/logs/BE mkdir -p /data/logs/FE chmod 777 /data chmod 777 /data/logs } # _setup_docker_aliases() - Function that setups the aliases required by sdc scripts function _setup_docker_aliases { cat < /root/.bash_aliases alias dcls='/data/scripts/docker_clean.sh \$1' alias dlog='/data/scripts/docker_login.sh \$1' alias drun='/data/scripts/docker_run.sh' alias health='/data/scripts/docker_health.sh' EOL } # get_sdc_images() - Function that retrieves the SDC docker images function get_sdc_images { build_docker_image ${src_folders[sdc]}/utils/webseal-simulator docker if [[ "$build_image" == "True" ]]; then build_docker_image ${src_folders[sdc]}/sdc-docker-base compile_src ${src_folders[sdc]} for project in catalog-fe test-apis-ci; do compile_src ${src_folders[sdc]}/$project done build_docker_image ${src_folders[sdc]}/sdc-os-chef docker else for image in elasticsearch init-elasticsearch cassandra kibana backend frontend sanity; do pull_onap_image sdc-$image & done wait_docker_pull fi } # install_sdc() - Function that pull templates and executes function install_sdc { local ENV_NAME=$dmaap_topic local MR_IP_ADDR='10.0.11.1' _init_data_folders cp ${src_folders[sdc]}/sdc-os-chef/environments/Template.json /data/environments cp ${src_folders[sdc]}/sdc-os-chef/scripts/docker_run.sh /data/scripts cp ${src_folders[sdc]}/sdc-os-chef/scripts/docker_health.sh /data/scripts cp ${src_folders[sdc]}/sdc-os-chef/scripts/docker_login.sh /data/scripts cp ${src_folders[sdc]}/sdc-os-chef/scripts/docker_clean.sh /data/scripts cp ${src_folders[sdc]}/sdc-os-chef/scripts/simulator_docker_run.sh /data/scripts chmod +x /data/scripts/*.sh cat /data/environments/Template.json | sed "s/yyy/"$IP_ADDRESS"/g" > /data/environments/$ENV_NAME.json sed -i "s/xxx/"$ENV_NAME"/g" /data/environments/$ENV_NAME.json sed -i "s/\"ueb_url_list\":.*/\"ueb_url_list\": \""$MR_IP_ADDR","$MR_IP_ADDR"\",/g" /data/environments/$ENV_NAME.json sed -i "s/\"fqdn\":.*/\"fqdn\": [\""$MR_IP_ADDR"\", \""$MR_IP_ADDR"\"]/g" /data/environments/$ENV_NAME.json install_docker if [[ "$skip_get_images" == "False" ]]; then bash /data/scripts/docker_run.sh -e $ENV_NAME -l else bash /data/scripts/docker_run.sh -e $ENV_NAME -r $docker_version -p $(echo $nexus_docker_repo | cut -d':' -f2) fi } # init_sdc() - Function that initialize SDC services function init_sdc { mount_external_partition sdb /data/ if [[ "$clone_repo" == "True" ]]; then clone_repos "sdc" if [[ "$compile_repo" == "True" ]]; then compile_repos "sdc" fi fi if [[ "$skip_get_images" == "False" ]]; then get_sdc_images fi if [[ "$skip_install" == "False" ]]; then install_sdc fi _setup_docker_aliases }