blob: b987c4c962e1781eb171f25b68f077cb3a57f65a [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 Morales165f3e32017-08-08 16:24:05 -05006
7src_folder=$git_src_folder/policy
8policy_repos=("api" "common" "docker" "drools-applications" "drools-pdp" "engine" "gui" "pap" "pdp")
Victor Moralesdd074802017-07-26 16:06:35 -05009
10# clone_all_policy_repos() - Function that clones Policy source repo.
11function clone_all_policy_repos {
Victor Morales165f3e32017-08-08 16:24:05 -050012 for dirc in ${aai_repos[@]}; do
Victor Moralesdd074802017-07-26 16:06:35 -050013 clone_repo policy/$dirc $src_folder/$dirc
14 done
15}
16
17# # compile_all_policy_repos() - Function that compiles Policy source repo.
18function compile_all_policy_repos {
Victor Morales165f3e32017-08-08 16:24:05 -050019 for dirc in ${aai_repos[@]}; do
Victor Moralesdd074802017-07-26 16:06:35 -050020 compile_src $src_folder/$dirc
21 done
22}
23
Victor Morales89ce3212017-06-16 18:32:48 -050024# install_policy() - Function that clones and installs the Policy services from source code
25function install_policy {
Victor Moralesdd074802017-07-26 16:06:35 -050026 if [[ "$build_image" == "True" ]]; then
27 compile_src $src_folder/docker
28 install_docker
29 pushd $src_folder/docker
Victor Morales165f3e32017-08-08 16:24:05 -050030 install_maven
31 mvn prepare-package
32 cp -r target/policy-pe/* policy-pe/
33 cp -r target/policy-drools/* policy-drools
Victor Moralesdd074802017-07-26 16:06:35 -050034 bash docker_verify.sh
35 for image in os nexus db base drools pe; do
36 asserts_image onap/policy/policy-$image
37 done
38 popd
39 else
40 pull_onap_image policy/policy-db onap/policy/policy-db:latest
41 pull_onap_image policy/policy-pe onap/policy/policy-pe:latest
42 pull_onap_image policy/policy-drools onap/policy/policy-drools:latest
43 pull_onap_image policy/policy-nexus onap/policy/policy-nexus:latest
44 fi
45 pushd $src_folder/docker
Victor Morales89ce3212017-06-16 18:32:48 -050046 chmod +x config/drools/drools-tweaks.sh
47 IP_ADDRESS=$(ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
48 echo $IP_ADDRESS > config/pe/ip_addr.txt
49 install_docker_compose
50 /opt/docker/docker-compose up -d
51 popd
52}
53
54# init_policy() - Function that initialize Policy services
55function init_policy {
Victor Morales165f3e32017-08-08 16:24:05 -050056 clone_all_policy_repos
57 if [[ "$compile_repo" == "True" ]]; then
58 compile_all_policy_repos
59 fi
60
Victor Morales89ce3212017-06-16 18:32:48 -050061 install_policy
62}