Add missing library
[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 ################ Check for java
21 sudo apt-get install -y wget unzip
22
23 #check for java
24 java -version
25 if [ $? == 127 ]
26 then
27     sudo apt-get install -y openjdk-8-jre
28 fi
29
30 echo ################ Install OCLIP
31
32 VTP_LATEST_BINARY="https://nexus.onap.org/service/local/artifact/maven/redirect?r=releases&g=org.onap.cli&a=cli-zip&e=zip&v=LATEST"
33 VTP_INSTALL_DIR=/opt/vtp
34 VTP_ZIP=vtp.zip
35
36 mkdir -p $VTP_INSTALL_DIR
37 cd $VTP_INSTALL_DIR
38
39 wget -O $VTP_ZIP $VTP_LATEST_BINARY
40 unzip $VTP_ZIP
41
42 export OPEN_CLI_HOME=$VTP_INSTALL_DIR
43 export OPEN_CLI_PRODUCT_IN_USE=onap-vtp
44
45 cd $OPEN_CLI_HOME
46
47 if [ ! -d ./data ]; then mkdir ./data; fi
48 if [ ! -d ./open-cli-schema ]; then mkdir ./open-cli-schema; fi
49
50 for cmd in ./bin/oclip.sh ./bin/oclip-rcli.sh ./bin/oclip-cmdflow-server.sh
51 do
52    sed '18i export OPEN_CLI_HOME=/opt/vtp' $cmd > ${cmd}_
53    mv ${cmd}_ ${cmd}
54 done
55
56 sudo chmod +x ./bin/oclip.sh
57 sudo chmod +x ./bin/oclip-rcli.sh
58 sudo chmod +x ./bin/oclip-grpc-server.sh
59
60 echo export OPEN_CLI_HOME=/opt/vtp > $OPEN_CLI_HOME/bin/vtp.sh
61 echo  $OPEN_CLI_HOME/bin/oclip-grpc-server.sh>> $OPEN_CLI_HOME/bin/vtp.sh
62 sudo chmod +x $OPEN_CLI_HOME/bin/vtp.sh
63
64 ln -sf $OPEN_CLI_HOME/bin/oclip.sh /usr/local/bin/oclip
65 ln -sf $OPEN_CLI_HOME/bin/oclip-rcli.sh /usr/local/bin/vtp-cli
66 ln -sf $OPEN_CLI_HOME/bin/oclip-grpc-server.sh /usr/local/bin/vtp-tc
67
68 echo ################ Deploy sample csar validation test case
69 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"
70 CSARVAL_ZIP=csarvalidator.zip
71 wget -O $CSARVAL_ZIP $CSARVALIDATOR_LATEST_BINARY
72 unzip -d csarvalidator $CSARVAL_ZIP
73 echo install csarvalidator into vtp
74 cp csarvalidator/commons-lang3*.jar $VTP_INSTALL_DIR/lib/
75 cp csarvalidator/validation-csar*.jar $VTP_INSTALL_DIR/lib/
76 cp csarvalidator/bcpkix-jdk15on-1.61.jar $VTP_INSTALL_DIR/lib/
77 cp csarvalidator/bcprov-jdk15on-1.61.jar $VTP_INSTALL_DIR/lib/
78 cp csarvalidator/commons-collections*.jar $VTP_INSTALL_DIR/lib/
79 rm -rf csarvalidator $CSARVAL_ZIP $VTP_ZIP
80 cd -
81
82 echo ################ Install as service
83 cp $_PWD/vtp-tc.sh /etc/init.d/vtp-tc && update-rc.d vtp-tc defaults
84
85 echo ################ Done