#!/bin/bash
#
#   Copyright 2016 Telefónica Investigación y Desarrollo, S.A.U.
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
# 
# Authors:
#    - Gerardo Garcia - gerardo.garciadeblas@telefonica.com
# 

HERE=$(realpath $(dirname $0))
OSM_JENKINS=$(dirname $HERE)
. $OSM_JENKINS/common/all_funcs

# SET YOUR MDG repository name here
export OSM_MDG=RO
OSM_load_config

. $OSM_JENKINS/common/install_common

# Installation starts here

#Release TWO

DEBIAN_FRONTEND=noninteractive add-apt-repository -y cloud-archive:ocata
apt-get update
apt-get -y install python-osm-ro

OSMIM_PATH=`python -c 'import osm_im; print osm_im.__path__[0]'` || FATAL "python-osm-im was not properly installed"
OSMLIBOVIM_PATH=`python -c 'import lib_osm_openvim; print lib_osm_openvim.__path__[0]'` || FATAL "python-lib-osm-openvim was not properly installed"
OSMRO_PATH=`python -c 'import osm_ro; print osm_ro.__path__[0]'` || FATAL "python-osm-ro was not properly installed"

DEBIAN_FRONTEND=noninteractive ${OSMRO_PATH}/database_utils/install-db-server.sh --updatedb || FATAL "osm-ro db installation failed"
DEBIAN_FRONTEND=noninteractive ${OSMLIBOVIM_PATH}/database_utils/install-db-server.sh -u mano -p manopw -d mano_vim_db --updatedb || FATAL "lib-osm-openvim db installation failed"
service osm-ro restart

RC=$?
INFO "done, RC=$RC"
exit $RC


