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