#!/bin/bash # Copyright 2015 Mellanox Technologies, Ltd # # 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. readonly PLUGIN_DIR="$(dirname $0)" readonly PLUGIN_VERSION=`cat ${PLUGIN_DIR}/.version` readonly REPOSITORY_PATH='bgate.mellanox.com/openstack/mellanox_fuel_plugin' function download { FILE_TYPE=$1 FILE_NAME=$2 case ${FILE_TYPE} in 'bootstrap') PREFIX_URL=$PLUGIN_VERSION/bootstrap/latest-build BUILD_DIR=bootstrap/ FILE_NAME=`curl http://${REPOSITORY_PATH}/${PREFIX_URL}/ | tr '<' '\n' | tr '>' '\n' | grep ^$FILE_NAME` ;; 'rpm') PREFIX_URL=$PLUGIN_VERSION/repositories/centos/Packages BUILD_DIR=repositories/centos/Packages ;; 'deb') PREFIX_URL=$PLUGIN_VERSION/repositories/ubuntu BUILD_DIR=repositories/ubuntu ;; *) echo "Can't download ${FILE_NAME}. File of type ${FILE_TYPE} is not supported." exit 1 esac URL="http://${REPOSITORY_PATH}/${PREFIX_URL}/${FILE_NAME}" DEST_DIR="${PLUGIN_DIR}/${BUILD_DIR}" wget ${URL} -P ${DEST_DIR} if [ $? -ne 0 ]; then echo "Failed fetching package from: ${URL} to ${DEST_DIR}" >&2 exit 1 fi } function get_packages() { file_type=$1 old_packages=$2 files=$3 rm -rf $old_packages for f in $files; do download $file_type $f done } old_debs="${PLUGIN_DIR}/repositories/ubuntu/*.deb" deb_files="cirros-testvm-mellanox_0.3.2-ubuntu3_amd64.deb cirros-testvm-mellanox-ib_0.3.2-9_amd64.deb eswitchd_1.0.0-18_amd64.deb mlnx-ofed-fuel_4.0-2.0.0.1_amd64.deb lldpd_0.9.1-0_amd64.deb python-networking-mlnx_7.0.0-1_all.deb" get_packages "deb" "$old_debs" "$deb_files"