Readds plugins code and respective tests
[osm/MON.git] / osm_mon / 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 THISHOST=$(hostname -f)
27 Domain_Name="${THISHOST}"
28 #Domain_Name="www.vrops_webservice.com"
29 WebServiceFile="${BASEDIR}/vrops_webservice"
30
31 echo '
32 #################################################################
33 ##### Installing Require Packages #####
34 #################################################################'
35
36 #Function to install packages using apt-get
37 function install_packages(){
38 [ -x /usr/bin/apt-get ] && apt-get install -y $*
39
40 #check properly installed
41 for PACKAGE in $*
42 do
43 PACKAGE_INSTALLED="no"
44 [ -x /usr/bin/apt-get ] && dpkg -l $PACKAGE &>> /dev/null && PACKAGE_INSTALLED="yes"
45 if [ "$PACKAGE_INSTALLED" = "no" ]
46 then
47 echo "failed to install package '$PACKAGE'. Revise network connectivity and try again" >&2
48 exit 1
49 fi
50 done
51 }
52
53 apt-get update # To get the latest package lists
54
55 [ "$_DISTRO" == "Ubuntu" ] && install_packages "python3-yaml python3-bottle python3-jsonschema python3-requests libxml2-dev libxslt-dev python3-dev python3-pip openssl"
56 [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "python3-jsonschema python3-requests libxslt-devel libxml2-devel python3-devel python3-pip openssl"
57 #The only way to install python-bottle on Centos7 is with easy_install or pip
58 [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && easy_install -U bottle
59
60 #required for vmware connector TODO move that to separete opt in install script
61 pip3 install pip==9.0.3
62 pip3 install cherrypy
63
64 echo '
65 #################################################################
66 ##### Genrate SSL Certificate #####
67 #################################################################'
68 #Create SSL Certifcate folder and file
69 mkdir "${SSL_Cert_Dir}"
70
71 openssl genrsa -out "${SSL_Cert_Dir}/${Domain_Name}".key 2048
72 openssl req -new -x509 -key "${SSL_Cert_Dir}/${Domain_Name}".key -out "${SSL_Cert_Dir}/${Domain_Name}".cert -days 3650 -subj /CN="${Domain_Name}"
73
74 echo '
75 #################################################################
76 ##### Start Web Service #####
77 #################################################################'
78
79 nohup python3 "${WebServiceFile}" &
80
81 echo '
82 #################################################################
83 ##### Done #####
84 #################################################################'
85
86