Merge "Updated Code of AWS plugin including Minor alternations of consumer/producer...
[osm/MON.git] / plugins / vRealiseOps / vROPs_Webservice / install.sh
1 #!/usr/bin/env bash
2
3 ##
4 # Copyright 2016-2017 VMware Inc.
5 # This file is part of ETSI OSM
6 # All Rights Reserved.
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License"); you may
9 # not use this file except in compliance with the License. You may obtain
10 # a copy of the License at
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 # License for the specific language governing permissions and limitations
18 # under the License.
19 #
20 # For those usages not covered by the Apache License, Version 2.0 please
21 # contact: osslegalrouting@vmware.com
22 ##
23
24 BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
25 SSL_Cert_Dir="${BASEDIR}/SSL_certificate"
26 Domain_Name="www.vrops_webservice.com"
27 WebServiceFile='vrops_webservice.py'
28
29 echo '
30 #################################################################
31 ##### Installing Require Packages #####
32 #################################################################'
33
34 #Function to install packages using apt-get
35 function install_packages(){
36 [ -x /usr/bin/apt-get ] && apt-get install -y $*
37
38 #check properly installed
39 for PACKAGE in $*
40 do
41 PACKAGE_INSTALLED="no"
42 [ -x /usr/bin/apt-get ] && dpkg -l $PACKAGE &>> /dev/null && PACKAGE_INSTALLED="yes"
43 if [ "$PACKAGE_INSTALLED" = "no" ]
44 then
45 echo "failed to install package '$PACKAGE'. Revise network connectivity and try again" >&2
46 exit 1
47 fi
48 done
49 }
50
51 apt-get update # To get the latest package lists
52
53 [ "$_DISTRO" == "Ubuntu" ] && install_packages "python-yaml python-bottle python-jsonschema python-requests libxml2-dev libxslt-dev python-dev python-pip openssl"
54 [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "python-jsonschema python-requests libxslt-devel libxml2-devel python-devel python-pip openssl"
55 #The only way to install python-bottle on Centos7 is with easy_install or pip
56 [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && easy_install -U bottle
57
58 #required for vmware connector TODO move that to separete opt in install script
59 sudo pip install --upgrade pip
60 sudo pip install cherrypy
61
62 echo '
63 #################################################################
64 ##### Genrate SSL Certificate #####
65 #################################################################'
66 #Create SSL Certifcate folder and file
67 mkdir "${SSL_Cert_Dir}"
68
69 openssl genrsa -out "${SSL_Cert_Dir}/${Domain_Name}".key 2048
70 openssl req -new -x509 -key "${SSL_Cert_Dir}/${Domain_Name}".key -out "${SSL_Cert_Dir}/${Domain_Name}".cert -days 3650 -subj /CN="${Domain_Name}"
71
72 echo '
73 #################################################################
74 ##### Start Web Service #####
75 #################################################################'
76
77 nohup python "${WebServiceFile}" &
78
79 echo '
80 #################################################################
81 ##### Done #####
82 #################################################################'