Fuel plugin to collect Logging Monitoring and Alerting metrics
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.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. # Copyright 2015 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 official Puppet module and store it in the local directory
  39. function download_puppet_module {
  40. rm -rf "${MODULES_DIR:?}"/"$1"
  41. mkdir -p "${MODULES_DIR}"/"$1"
  42. wget -qO- "$2" | tar -C "${MODULES_DIR}/$1" --strip-components=1 -xz
  43. }
  44. function check_md5sum {
  45. FILE="$(get_package_path "$1")"
  46. echo "$2 $FILE" | md5sum --check --strict
  47. }