blob: f99fd60424680ab071990953bc78cefe7148d169 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
Victor Moralesdd074802017-07-26 16:06:35 -05005source /var/onap/functions
Victor Moralesdd074802017-07-26 16:06:35 -05006
Victor Morales7ba76472017-08-23 15:19:36 -05007vid_src_folder=$git_src_folder/vid
Victor Morales21404d72017-10-20 13:18:26 -07008vid_repos=("vid" "vid/asdcclient")
Victor Morales89ce3212017-06-16 18:32:48 -05009
Victor Moralesdd074802017-07-26 16:06:35 -050010# clone_all_vid_repos() - Function that clones VID source code.
11function clone_all_vid_repos {
Victor Morales21404d72017-10-20 13:18:26 -070012 for repo in ${vid_repos[@]}; do
13 clone_repo $repo $vid_src_folder${repo#*vid}
14 done
Victor Moralesdd074802017-07-26 16:06:35 -050015}
16
17# compile_all_vid_repos() - Function that compiles VID source repo.
18function compile_all_vid_repos {
Victor Morales21404d72017-10-20 13:18:26 -070019 for repo in ${vid_repos[@]}; do
20 compile_src $vid_src_folder${repo#*vid}
21 done
Victor Morales7ba76472017-08-23 15:19:36 -050022}
23
24# _build_vid_images() - Function that builds VID docker images
25function _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
33function 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 Moralesdd074802017-07-26 16:06:35 -050040}
41
Victor Morales89ce3212017-06-16 18:32:48 -050042# install_vid() - Download and configure Vid source code
43function install_vid {
Victor Morales7ba76472017-08-23 15:19:36 -050044 vid_image=`docker images | grep vid | grep latest| awk '{print $1 ":" $2}'`
Victor Morales89ce3212017-06-16 18:32:48 -050045
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 Moralesdd074802017-07-26 16:06:35 -050050 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 Morales89ce3212017-06-16 18:32:48 -050051}
52
53# init_vid() - Function that initialize Vid services
54function init_vid {
Idan Amit1690e082017-08-20 08:58:14 +030055 if [[ "$clone_repo" == "True" ]]; then
56 clone_all_vid_repos
57 if [[ "$compile_repo" == "True" ]]; then
58 compile_all_vid_repos
59 fi
Victor Morales7ba76472017-08-23 15:19:36 -050060 fi
61
Victor Morales6a919972017-09-28 18:29:54 -070062 if [[ "$skip_get_images" == "False" ]]; then
63 get_vid_images
64 if [[ "$skip_install" == "False" ]]; then
65 install_vid
66 fi
67 fi
Victor Morales89ce3212017-06-16 18:32:48 -050068}