Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -o xtrace |
| 4 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 5 | source /var/onap/functions |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 6 | |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 7 | sdc_src_folder=$git_src_folder/sdc |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 8 | sdc_repos=("sdc" "sdc/jtosca" "sdc/sdc-distribution-client" |
| 9 | "sdc/sdc-docker-base" "sdc/sdc-titan-cassandra" "sdc/sdc-tosca" |
| 10 | "sdc/sdc-vnfdesign" "sdc/sdc-workflow-designer" "sdc/sdc_common") |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 11 | |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 12 | # _mount_external_partition() - Create partition and mount the external volume |
| 13 | function _mount_external_partition { |
Idan Amit | bf1e7f0 | 2017-08-20 16:05:46 +0300 | [diff] [blame] | 14 | cat <<EOL > /tmp/sdc_ext_volume_partitions.txt |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 15 | # partition table of /dev/sdb |
| 16 | unit: sectors |
| 17 | |
| 18 | /dev/sdb1 : start= 2048, size=209713152, Id=83 |
| 19 | /dev/sdb2 : start= 0, size= 0, Id= 0 |
| 20 | /dev/sdb3 : start= 0, size= 0, Id= 0 |
| 21 | /dev/sdb4 : start= 0, size= 0, Id= 0 |
| 22 | EOL |
Idan Amit | bf1e7f0 | 2017-08-20 16:05:46 +0300 | [diff] [blame] | 23 | sfdisk --force /dev/sdb < /tmp/sdc_ext_volume_partitions.txt |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 24 | mkfs -t ext4 /dev/sdb1 |
| 25 | mkdir -p /data |
| 26 | mount /dev/sdb1 /data |
| 27 | echo "/dev/sdb1 /data ext4 errors=remount-ro,noatime,barrier=0 0 1" >> /etc/fstab |
| 28 | } |
| 29 | |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 30 | # _init_data_folders() - Function that initialize the data folders |
| 31 | function _init_data_folders { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 32 | mkdir -p /data/environments |
| 33 | mkdir -p /data/scripts |
| 34 | mkdir -p /data/logs/BE |
| 35 | mkdir -p /data/logs/FE |
| 36 | chmod 777 /data |
Idan Amit | c46e98f | 2017-08-21 17:04:10 +0300 | [diff] [blame] | 37 | chmod 777 /data/logs |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 38 | } |
| 39 | |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 40 | # _setup_docker_aliases() - Function that setups the aliases required by sdc scripts |
| 41 | function _setup_docker_aliases { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 42 | cat <<EOL > /root/.bash_aliases |
| 43 | alias dcls='/data/scripts/docker_clean.sh \$1' |
| 44 | alias dlog='/data/scripts/docker_login.sh \$1' |
Idan Amit | 8e393c3 | 2017-09-27 17:55:52 +0300 | [diff] [blame] | 45 | alias drun='/data/scripts/docker_run.sh' |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 46 | alias health='/data/scripts/docker_health.sh' |
| 47 | EOL |
| 48 | } |
| 49 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 50 | # clone_all_sdc_repos() - Function that clones SDC source repo. |
| 51 | function clone_all_sdc_repos { |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 52 | for repo in ${sdc_repos[@]}; do |
| 53 | clone_repo $repo $sdc_src_folder${repo#*sdc} |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 54 | done |
| 55 | } |
| 56 | |
| 57 | # compile_all_sdc_repos() - Function that compiles SDC source repo. |
| 58 | function compile_all_sdc_repos { |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 59 | for repo in ${sdc_repos[@]}; do |
| 60 | compile_src $sdc_src_folder${repo#*sdc} |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 61 | done |
| 62 | } |
| 63 | |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 64 | # get_sdc_images() - Function that retrieves the SDC docker images |
| 65 | function get_sdc_images { |
| 66 | if [[ "$build_image" == "True" ]]; then |
Victor Morales | dbe2e0b | 2017-09-20 09:55:45 -0700 | [diff] [blame] | 67 | build_docker_image $sdc_src_folder/sdc-docker-base |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 68 | else |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 69 | for image in backend frontend elasticsearch kibana cassandra sanity; do |
| 70 | pull_openecomp_image openecomp/sdc-$image |
| 71 | done |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 72 | fi |
| 73 | } |
| 74 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 75 | # install_sdc() - Function that pull templates and executes |
| 76 | function install_sdc { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 77 | local ENV_NAME=$dmaap_topic |
| 78 | local MR_IP_ADDR='10.0.11.1' |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 79 | |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 80 | _init_data_folders |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 81 | cp $sdc_src_folder/sdc-os-chef/environments/Template.json /data/environments |
| 82 | cp $sdc_src_folder/sdc-os-chef/scripts/docker_run.sh /data/scripts |
| 83 | cp $sdc_src_folder/sdc-os-chef/scripts/docker_health.sh /data/scripts |
| 84 | cp $sdc_src_folder/sdc-os-chef/scripts/docker_login.sh /data/scripts |
| 85 | cp $sdc_src_folder/sdc-os-chef/scripts/docker_clean.sh /data/scripts |
| 86 | chmod +x /data/scripts/docker_run.sh |
| 87 | chmod +x /data/scripts/docker_health.sh |
| 88 | chmod +x /data/scripts/docker_login.sh |
| 89 | chmod +x /data/scripts/docker_clean.sh |
| 90 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 91 | cat /data/environments/Template.json | sed "s/yyy/"$IP_ADDRESS"/g" > /data/environments/$ENV_NAME.json |
| 92 | sed -i "s/xxx/"$ENV_NAME"/g" /data/environments/$ENV_NAME.json |
| 93 | sed -i "s/\"ueb_url_list\":.*/\"ueb_url_list\": \""$MR_IP_ADDR","$MR_IP_ADDR"\",/g" /data/environments/$ENV_NAME.json |
| 94 | sed -i "s/\"fqdn\":.*/\"fqdn\": [\""$MR_IP_ADDR"\", \""$MR_IP_ADDR"\"]/g" /data/environments/$ENV_NAME.json |
| 95 | |
Idan Amit | 0a29555 | 2017-08-17 17:03:59 +0300 | [diff] [blame] | 96 | install_docker |
Victor Morales | a44489e | 2017-10-05 08:18:01 -0700 | [diff] [blame] | 97 | if [[ "$skip_get_images" == "False" ]]; then |
| 98 | bash /data/scripts/docker_run.sh -e $ENV_NAME -l |
| 99 | else |
| 100 | bash /data/scripts/docker_run.sh -e $ENV_NAME -r $docker_version -p $(echo $nexus_docker_repo | cut -d':' -f2) |
| 101 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 102 | } |
| 103 | |
Idan Amit | bf1e7f0 | 2017-08-20 16:05:46 +0300 | [diff] [blame] | 104 | # init_sdc() - Function that initialize SDC services |
| 105 | function init_sdc { |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 106 | _mount_external_partition |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 107 | if [[ "$clone_repo" == "True" ]]; then |
| 108 | clone_all_sdc_repos |
| 109 | if [[ "$compile_repo" == "True" ]]; then |
| 110 | compile_all_sdc_repos |
| 111 | fi |
| 112 | fi |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 113 | |
| 114 | if [[ "$skip_get_images" == "False" ]]; then |
| 115 | get_sdc_images |
Victor Morales | a44489e | 2017-10-05 08:18:01 -0700 | [diff] [blame] | 116 | fi |
| 117 | if [[ "$skip_install" == "False" ]]; then |
| 118 | install_sdc |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 119 | fi |
Victor Morales | e746700 | 2017-08-30 14:50:43 -0500 | [diff] [blame] | 120 | _setup_docker_aliases |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 121 | } |