Dynamic preload vFWDT
[demo.git] / heat / ONAP / cloud-config / cli_install.sh
1 #!/bin/bash
2
3 #*******************************************************************************
4 # Copyright 2017 Huawei Technologies Co., Ltd.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #*******************************************************************************
18
19 CLI_LATEST_BINARY="https://nexus.onap.org/content/repositories/releases/org/onap/cli/cli-zip/1.1.0/cli-zip-1.1.0.zip"
20 CLI_INSTALL_DIR=/opt/onap/cli
21 CLI_ZIP=cli.zip
22 CLI_BIN=/usr/bin/onap
23 HTTP_PROXY=$(cat /opt/config/http_proxy.txt)
24 HTTPS_PROXY=$(cat /opt/config/https_proxy.txt)
25
26 if [ $HTTP_PROXY != "no_proxy" ]
27 then
28     export http_proxy=$HTTP_PROXY
29     export https_proxy=$HTTPS_PROXY
30 fi
31
32 export ONAP_CLI_HOME=$CLI_INSTALL_DIR
33 export CLI_PRODUCT_VERSION=onap-1.1
34
35 #create install dir
36 if [ -d $CLI_INSTALL_DIR ]
37 then
38     mv $CLI_INSTALL_DIR $CLI_INSTALL_DIR/../cli_`date +"%m-%d-%y-%H-%M-%S"`
39     rm $CLI_BIN
40 fi
41
42 mkdir -p $CLI_INSTALL_DIR
43 cd $CLI_INSTALL_DIR
44
45 #Download and unzip CLI
46 apt-get install -y wget unzip
47
48 #check for java
49 java -version
50 if [ $? == 127 ]
51 then
52     apt-get install -y openjdk-8-jre
53 fi
54
55 wget -O $CLI_ZIP $CLI_LATEST_BINARY
56
57 unzip $CLI_ZIP
58 if [ ! -d ./data ]; then mkdir ./data; fi
59 if [ ! -d ./onap-cli-schema ]; then mkdir ./onap-cli-schema; fi
60 chmod +x ./bin/onap.sh
61
62 #Make onap available in path
63 ln ./bin/onap.sh $CLI_BIN
64
65 #Print the version
66 onap -v
67
68 cd -