create_nagios_addon_deb.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. #
  3. #/*
  4. # * Licensed to the Apache Software Foundation (ASF) under one
  5. # * or more contributor license agreements. See the NOTICE file
  6. # * distributed with this work for additional information
  7. # * regarding copyright ownership. The ASF licenses this file
  8. # * to you under the Apache License, Version 2.0 (the
  9. # * "License"); you may not use this file except in compliance
  10. # * with the License. You may obtain a copy of the License at
  11. # *
  12. # * http://www.apache.org/licenses/LICENSE-2.0
  13. # *
  14. # * Unless required by applicable law or agreed to in writing, software
  15. # * distributed under the License is distributed on an "AS IS" BASIS,
  16. # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. # * See the License for the specific language governing permissions and
  18. # * limitations under the License.
  19. # */
  20. CUR_DIR=`pwd`
  21. BASEDIR="$( cd "$( dirname "$0" )" && pwd )"
  22. if [[ -z "${BUILD_DIR}" ]]; then
  23. BUILD_DIR="${BASEDIR}/build/"
  24. fi
  25. if [[ -z "${VERSION}" ]]; then
  26. VERSION=${VERSION:-1.7.0}
  27. fi
  28. if [[ -z "${RELEASE}" ]]; then
  29. RELEASE=${RELEASE:-1}
  30. fi
  31. rm -rf ${BUILD_DIR}/*
  32. PKG_NAME="hdp_mon_nagios_addons"
  33. PKG_FULL_NAME="${PKG_NAME}-$VERSION"
  34. MON_TAR_DIR="${BUILD_DIR}/${PKG_FULL_NAME}/"
  35. SRC_DIR="${BASEDIR}/../../src/addOns/nagios/"
  36. NAGIOS_ALERTS_DIR="${BASEDIR}/../../../nagios-alerts"
  37. ############ Mapping
  38. mkdir -p "${MON_TAR_DIR}/usr/lib64/nagios"
  39. cp -r "${SRC_DIR}/plugins" "${MON_TAR_DIR}/usr/lib64/nagios"
  40. cp -r "${NAGIOS_ALERTS_DIR}/plugins" "${MON_TAR_DIR}/usr/lib64/nagios"
  41. mkdir -p "${MON_TAR_DIR}/etc/apache2"
  42. cp -r "${SRC_DIR}/conf.d" "${MON_TAR_DIR}/etc/apache2"
  43. mkdir -p "${MON_TAR_DIR}/usr/share/hdp/nagios"
  44. cp -r ${SRC_DIR}/scripts/* "${MON_TAR_DIR}/usr/share/hdp/nagios"
  45. ############ Create data tar
  46. cd ${BUILD_DIR}
  47. tar -zcvf data.tar.gz -C "$PKG_FULL_NAME" .
  48. ############ Create control archive
  49. cp "${BASEDIR}/nagios_addon_deb_control" "${BUILD_DIR}/control"
  50. TAR_CONTROL_DEST="${BUILD_DIR}/control.tar.gz"
  51. tar -czf "${TAR_CONTROL_DEST}" control
  52. ############ Create debian-binary
  53. echo "2.0" > debian-binary
  54. ############ Pack to deb package
  55. ar rcv "$PKG_FULL_NAME.deb" debian-binary control.tar.gz data.tar.gz