85 lines
2.9 KiB
Bash
Executable File
85 lines
2.9 KiB
Bash
Executable File
#!/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_rpms="${PLUGIN_DIR}/repositories/centos/Packages/*.rpm"
|
|
rpm_files="cirros-testvm-mellanox-0.3.2-1.mira3.x86_64.rpm
|
|
cirros-testvm-mellanox-ib-0.3.2-7.el6.x86_64.rpm
|
|
eswitchd-0.11-5.el6.x86_64.rpm
|
|
mlnx-dnsmasq-2014.2.2-1.noarch.rpm
|
|
mlnx-ofed-fuel-2.3-2.0.8.el6.x86_64.rpm
|
|
redhat-rpm-config-9.0.3-42.el6.centos.noarch.rpm"
|
|
#get_packages "rpm" "$old_rpms" "$rpm_files" # CentOS is not supported in 7.0
|
|
|
|
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_3.1-1.5.7_amd64.deb
|
|
mlnx-ofed-kernel-dkms_3.1-OFED.3.1.1.0.3.1.g9032737_all.deb
|
|
mlnx-ofed-kernel-utils_3.1-OFED.3.1.1.0.3.1.g9032737_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"
|
|
|
|
bootstrap_dir="${PLUGIN_DIR}/bootstrap/"
|
|
bootstrap_files="initrd_mlnx_mos*"
|
|
get_packages "bootstrap" "$bootstrap_dir/$bootstrap_files" "$bootstrap_files"
|