| #!/bin/bash |
| |
| set -o xtrace |
| |
| source /var/onap/functions |
| |
| sdc_src_folder=$git_src_folder/sdc |
| sdc_repos=("sdc" "sdc/jtosca" "sdc/sdc-distribution-client" |
| "sdc/sdc-docker-base" "sdc/sdc-titan-cassandra" "sdc/sdc-tosca" |
| "sdc/sdc-vnfdesign" "sdc/sdc-workflow-designer" "sdc/sdc_common") |
| |
| # _mount_external_partition() - Create partition and mount the external volume |
| function _mount_external_partition { |
| cat <<EOL > /tmp/sdc_ext_volume_partitions.txt |
| # partition table of /dev/sdb |
| unit: sectors |
| |
| /dev/sdb1 : start= 2048, size=209713152, Id=83 |
| /dev/sdb2 : start= 0, size= 0, Id= 0 |
| /dev/sdb3 : start= 0, size= 0, Id= 0 |
| /dev/sdb4 : start= 0, size= 0, Id= 0 |
| EOL |
| sfdisk --force /dev/sdb < /tmp/sdc_ext_volume_partitions.txt |
| mkfs -t ext4 /dev/sdb1 |
| mkdir -p /data |
| mount /dev/sdb1 /data |
| echo "/dev/sdb1 /data ext4 errors=remount-ro,noatime,barrier=0 0 1" >> /etc/fstab |
| } |
| |
| # _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 <<EOL > /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 |
| } |
| |
| # clone_all_sdc_repos() - Function that clones SDC source repo. |
| function clone_all_sdc_repos { |
| for repo in ${sdc_repos[@]}; do |
| clone_repo $repo $sdc_src_folder${repo#*sdc} |
| done |
| } |
| |
| # compile_all_sdc_repos() - Function that compiles SDC source repo. |
| function compile_all_sdc_repos { |
| for repo in ${sdc_repos[@]}; do |
| compile_src $sdc_src_folder${repo#*sdc} |
| done |
| } |
| |
| # get_sdc_images() - Function that retrieves the SDC docker images |
| function get_sdc_images { |
| if [[ "$build_image" == "True" ]]; then |
| build_docker_image $sdc_src_folder/sdc-docker-base |
| else |
| for image in backend frontend elasticsearch kibana cassandra sanity; do |
| pull_openecomp_image openecomp/sdc-$image |
| done |
| 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 $sdc_src_folder/sdc-os-chef/environments/Template.json /data/environments |
| cp $sdc_src_folder/sdc-os-chef/scripts/docker_run.sh /data/scripts |
| cp $sdc_src_folder/sdc-os-chef/scripts/docker_health.sh /data/scripts |
| cp $sdc_src_folder/sdc-os-chef/scripts/docker_login.sh /data/scripts |
| cp $sdc_src_folder/sdc-os-chef/scripts/docker_clean.sh /data/scripts |
| chmod +x /data/scripts/docker_run.sh |
| chmod +x /data/scripts/docker_health.sh |
| chmod +x /data/scripts/docker_login.sh |
| chmod +x /data/scripts/docker_clean.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 |
| if [[ "$clone_repo" == "True" ]]; then |
| clone_all_sdc_repos |
| if [[ "$compile_repo" == "True" ]]; then |
| compile_all_sdc_repos |
| fi |
| fi |
| |
| if [[ "$skip_get_images" == "False" ]]; then |
| get_sdc_images |
| fi |
| if [[ "$skip_install" == "False" ]]; then |
| install_sdc |
| fi |
| _setup_docker_aliases |
| } |