82ecb3afed7297b22846f69559027a46a2246076
[vnfsdk/refrepo.git] / vnfmarket-be / deployment / docker / docker-refrepo / src / main / docker / install-vtp.sh
1 #!/bin/bash
2 #
3 # Copyright 2018 Huawei Technologies Co., Ltd.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17
18 export _PWD=`pwd`
19
20 echo ################ Make sure that mandatory libraries are installed
21 sudo apt-get update --fix-missing -y
22 sudo apt-get install -y wget unzip
23
24 #check for java
25 java -version
26 if [ $? == 127 ]
27 then
28     sudo apt-get install -y openjdk-11-jre
29 fi
30
31 echo ################ Install OCLIP
32
33 OCLIP_VERSION="6.0.0"
34 VTP_LATEST_BINARY="https://nexus.onap.org/service/local/artifact/maven/redirect?r=releases&g=org.onap.cli&a=cli-zip&e=zip&v=$OCLIP_VERSION"
35 VTP_INSTALL_DIR=/opt/vtp
36 VTP_ZIP=vtp.zip
37
38 mkdir -p $VTP_INSTALL_DIR
39 cd $VTP_INSTALL_DIR
40
41 wget -O $VTP_ZIP $VTP_LATEST_BINARY
42 unzip $VTP_ZIP
43
44 export OPEN_CLI_HOME=$VTP_INSTALL_DIR
45 export OPEN_CLI_PRODUCT_IN_USE=onap-vtp
46
47 cd $OPEN_CLI_HOME
48
49 if [ ! -d ./data ]; then mkdir ./data; fi
50 if [ ! -d ./open-cli-schema ]; then mkdir ./open-cli-schema; fi
51
52 for cmd in ./bin/oclip.sh ./bin/oclip-rcli.sh ./bin/oclip-cmdflow-server.sh
53 do
54    sed '18i export OPEN_CLI_HOME=/opt/vtp' $cmd > ${cmd}_
55    mv ${cmd}_ ${cmd}
56 done
57
58 sudo chmod +x ./bin/oclip.sh
59 sudo chmod +x ./bin/oclip-rcli.sh
60 sudo chmod +x ./bin/oclip-grpc-server.sh
61
62 echo export OPEN_CLI_HOME=/opt/vtp > $OPEN_CLI_HOME/bin/vtp.sh
63 echo  $OPEN_CLI_HOME/bin/oclip-grpc-server.sh>> $OPEN_CLI_HOME/bin/vtp.sh
64 sudo chmod +x $OPEN_CLI_HOME/bin/vtp.sh
65
66 ln -sf $OPEN_CLI_HOME/bin/oclip.sh /usr/local/bin/oclip
67 ln -sf $OPEN_CLI_HOME/bin/oclip-rcli.sh /usr/local/bin/vtp-cli
68 ln -sf $OPEN_CLI_HOME/bin/oclip-grpc-server.sh /usr/local/bin/vtp-tc
69
70 echo ################ Deploy sample csar validation test case
71 CSARVALIDATOR_LATEST_BINARY="https://nexus.onap.org/service/local/artifact/maven/redirect?r=releases&g=org.onap.vnfsdk.validation&a=csarvalidation-deployment&e=zip&v=LATEST"
72 CSARVAL_ZIP=csarvalidator.zip
73 wget -O $CSARVAL_ZIP $CSARVALIDATOR_LATEST_BINARY
74 unzip -d csarvalidator $CSARVAL_ZIP
75 echo install csarvalidator into vtp
76 cp csarvalidator/commons-lang3*.jar $VTP_INSTALL_DIR/lib/
77 cp csarvalidator/bcpkix-jdk15on-1.61.jar $VTP_INSTALL_DIR/lib/
78 cp csarvalidator/bcprov-jdk15on-1.61.jar $VTP_INSTALL_DIR/lib/
79 cp csarvalidator/commons-collections*.jar $VTP_INSTALL_DIR/lib/
80 cp csarvalidator/snakeyaml-1.26.jar $VTP_INSTALL_DIR/lib/
81 cp csarvalidator/validation-csar*.jar $VTP_INSTALL_DIR/lib/
82 cp csarvalidator/validation-pmdictionary*.jar $VTP_INSTALL_DIR/lib/
83 rm -rf csarvalidator $CSARVAL_ZIP $VTP_ZIP
84 cd -
85
86 echo ################ Install as service
87 cp $_PWD/vtp-tc.sh /etc/init.d/vtp-tc && update-rc.d vtp-tc defaults
88
89 echo ################ Done