c5ec42169e455606e76f22ad108bec8e88dd57b3
[demo.git] / boot / 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/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.cli&a=cli-zip&e=zip&v=LATEST"
20 CLI_INSTALL_DIR=/opt/onap/cli
21 CLI_ZIP=cli.zip
22 CLI_BIN=/usr/bin/onap
23 export ONAP_CLI_HOME=$CLI_INSTALL_DIR
24 export CLI_PRODUCT_VERSION=onap-1.1
25
26 #create install dir
27 if [ -d $CLI_INSTALL_DIR ]
28 then
29     mv $CLI_INSTALL_DIR $CLI_INSTALL_DIR/../cli_`date +"%m-%d-%y-%H-%M-%S"`
30     rm $CLI_BIN
31 fi
32
33 mkdir -p $CLI_INSTALL_DIR
34 cd $CLI_INSTALL_DIR
35
36 #Download and unzip CLI
37 apt-get install -y wget unzip
38
39 #check for java
40 java -version
41 if [ $? == 127 ]
42 then
43     apt-get install -y openjdk-8-jre
44 fi
45
46 wget -O $CLI_ZIP $CLI_LATEST_BINARY
47
48 unzip $CLI_ZIP
49 if [ ! -d ./data ]; then mkdir ./data; fi
50 if [ ! -d ./onap-cli-schema ]; then mkdir ./onap-cli-schema; fi
51 chmod +x ./bin/onap.sh
52
53 #Make onap available in path
54 ln ./bin/onap.sh $CLI_BIN
55
56 #Print the version
57 onap -v
58
59 cd -