Fuel plugin to deploy OpenStack Telemetry services (Ceilometer, Aodh)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.sh 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # Copyright 2016 Mirantis, Inc.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -eux
  16. ROOT="$(dirname "$(readlink -f "$0")")"
  17. MODULES_DIR="${ROOT}"/deployment_scripts/puppet/modules
  18. RPM_REPO="${ROOT}"/repositories/centos
  19. DEB_REPO="${ROOT}"/repositories/ubuntu
  20. function get_package_path {
  21. FILE=$(basename "$1")
  22. if [[ "$1" == *.deb ]]; then
  23. echo "$DEB_REPO"/"$FILE"
  24. elif [[ "$1" == *.rpm ]]; then
  25. echo "$RPM_REPO"/"$FILE"
  26. else
  27. echo "Invalid URL for $1"
  28. exit 1
  29. fi
  30. }
  31. # Download RPM or DEB packages and store them in the local repository directory
  32. function download_packages {
  33. while [ $# -gt 0 ]; do
  34. wget -qO - "$1" > "$(get_package_path "$1")"
  35. shift
  36. done
  37. }
  38. # Download file and store it in the local directory
  39. function download_file {
  40. local URL=$1
  41. local FILE_NAME=$2
  42. local DESTINATION=$3
  43. mkdir -p $DESTINATION
  44. wget -qO $DESTINATION/$FILE_NAME $URL
  45. }
  46. # Download official Puppet module and store it in the local directory
  47. function download_puppet_module {
  48. rm -rf "${MODULES_DIR:?}"/"$1"
  49. mkdir -p "${MODULES_DIR}"/"$1"
  50. wget -qO- "$2" | tar -C "${MODULES_DIR}/$1" --strip-components=1 -xz
  51. }
  52. function check_md5sum {
  53. FILE="$(get_package_path "$1")"
  54. echo "$2 $FILE" | md5sum --check --strict
  55. }