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 | 7ba7647 | 2017-08-23 15:19:36 -0500 | [diff] [blame] | 7 | vid_src_folder=$git_src_folder/vid |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 8 | vid_repos=("vid" "vid/asdcclient") |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 9 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 10 | # clone_all_vid_repos() - Function that clones VID source code. |
| 11 | function clone_all_vid_repos { |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 12 | for repo in ${vid_repos[@]}; do |
| 13 | clone_repo $repo $vid_src_folder${repo#*vid} |
| 14 | done |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | # compile_all_vid_repos() - Function that compiles VID source repo. |
| 18 | function compile_all_vid_repos { |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 19 | for repo in ${vid_repos[@]}; do |
| 20 | compile_src $vid_src_folder${repo#*vid} |
| 21 | done |
Victor Morales | 7ba7647 | 2017-08-23 15:19:36 -0500 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | # _build_vid_images() - Function that builds VID docker images |
| 25 | function _build_vid_images { |
| 26 | if [[ "$compile_repo" != "True" ]]; then |
| 27 | compile_src $vid_src_folder |
| 28 | fi |
| 29 | build_docker_image $vid_src_folder/deliveries |
| 30 | } |
| 31 | |
| 32 | # get_vid_images() - Function that retrieves VID docker images |
| 33 | function get_vid_images { |
| 34 | if [[ "$build_image" == "True" ]]; then |
| 35 | _build_vid_images |
| 36 | else |
| 37 | pull_openecomp_image vid |
| 38 | fi |
| 39 | pull_docker_image mariadb:10 |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 40 | } |
| 41 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 42 | # install_vid() - Download and configure Vid source code |
| 43 | function install_vid { |
Victor Morales | 7ba7647 | 2017-08-23 15:19:36 -0500 | [diff] [blame] | 44 | vid_image=`docker images | grep vid | grep latest| awk '{print $1 ":" $2}'` |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 45 | |
| 46 | docker rm -f vid-mariadb |
| 47 | docker rm -f vid-server |
| 48 | |
| 49 | docker run --name vid-mariadb -e MYSQL_DATABASE=vid_openecomp -e MYSQL_USER=vidadmin -e MYSQL_PASSWORD=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U -e MYSQL_ROOT_PASSWORD=LF+tp_1WqgSY -v /opt/vid/lf_config/vid-my.cnf:/etc/mysql/my.cnf -v /opt/vid/lf_config/vid-pre-init.sql:/docker-entrypoint-initdb.d/vid-pre-init.sql -v /var/lib/mysql -d mariadb:10 |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 50 | docker run -e VID_MYSQL_DBNAME=vid_openecomp -e VID_MYSQL_PASS=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U --name vid-server -p 8080:8080 --link vid-mariadb:vid-mariadb-docker-instance -d $vid_image |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | # init_vid() - Function that initialize Vid services |
| 54 | function init_vid { |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 55 | if [[ "$clone_repo" == "True" ]]; then |
| 56 | clone_all_vid_repos |
| 57 | if [[ "$compile_repo" == "True" ]]; then |
| 58 | compile_all_vid_repos |
| 59 | fi |
Victor Morales | 7ba7647 | 2017-08-23 15:19:36 -0500 | [diff] [blame] | 60 | fi |
| 61 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 62 | if [[ "$skip_get_images" == "False" ]]; then |
| 63 | get_vid_images |
| 64 | if [[ "$skip_install" == "False" ]]; then |
| 65 | install_vid |
| 66 | fi |
| 67 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 68 | } |