create_nagios_addon_deb.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. ############ Mapping
  37. mkdir -p "${MON_TAR_DIR}/usr/lib64/nagios"
  38. cp -r "${SRC_DIR}/plugins" "${MON_TAR_DIR}/usr/lib64/nagios"
  39. mkdir -p "${MON_TAR_DIR}/etc/apache2"
  40. cp -r "${SRC_DIR}/conf.d" "${MON_TAR_DIR}/etc/apache2"
  41. mkdir -p "${MON_TAR_DIR}/usr/share/hdp/nagios"
  42. cp -r ${SRC_DIR}/scripts/* "${MON_TAR_DIR}/usr/share/hdp/nagios"
  43. ############ Create data tar
  44. cd ${BUILD_DIR}
  45. tar -zcvf data.tar.gz -C "$PKG_FULL_NAME" .
  46. ############ Create control archive
  47. cp "${BASEDIR}/nagios_addon_deb_control" "${BUILD_DIR}/control"
  48. TAR_CONTROL_DEST="${BUILD_DIR}/control.tar.gz"
  49. tar -czf "${TAR_CONTROL_DEST}" control
  50. ############ Create debian-binary
  51. echo "2.0" > debian-binary
  52. ############ Pack to deb package
  53. ar rcv "$PKG_FULL_NAME.deb" debian-binary control.tar.gz data.tar.gz