99-makeself.install.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/usr/bin/env bash
  2. # SPDX-License-Identifier: GPL-3.0-or-later
  3. # shellcheck source=packaging/makeself/functions.sh
  4. . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
  5. # shellcheck disable=SC2015
  6. [ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building self-extracting archive" || true
  7. run cd "${NETDATA_SOURCE_PATH}" || exit 1
  8. # -----------------------------------------------------------------------------
  9. # find the netdata version
  10. VERSION="$("${NETDATA_INSTALL_PARENT}/netdata/bin/netdata" -v | cut -f 2 -d ' ')"
  11. if [ "${VERSION}" == "" ]; then
  12. echo >&2 "Cannot find version number. Create makeself executable from source code with git tree structure."
  13. exit 1
  14. fi
  15. # -----------------------------------------------------------------------------
  16. # copy the files needed by makeself installation
  17. run mkdir -p "${NETDATA_INSTALL_PATH}/system"
  18. run cp \
  19. packaging/makeself/post-installer.sh \
  20. packaging/makeself/install-or-update.sh \
  21. packaging/installer/functions.sh \
  22. "${NETDATA_INSTALL_PATH}/system/"
  23. # -----------------------------------------------------------------------------
  24. # create a wrapper to start our netdata with a modified path
  25. run mkdir -p "${NETDATA_INSTALL_PATH}/bin/srv"
  26. run mv "${NETDATA_INSTALL_PATH}/bin/netdata" \
  27. "${NETDATA_INSTALL_PATH}/bin/srv/netdata" || exit 1
  28. cat > "${NETDATA_INSTALL_PATH}/bin/netdata" << EOF
  29. #!${NETDATA_INSTALL_PATH}/bin/bash
  30. export NETDATA_BASH_LOADABLES="DISABLE"
  31. export PATH="${NETDATA_INSTALL_PATH}/bin:\${PATH}"
  32. exec "${NETDATA_INSTALL_PATH}/bin/srv/netdata" "\${@}"
  33. EOF
  34. run chmod 755 "${NETDATA_INSTALL_PATH}/bin/netdata"
  35. # -----------------------------------------------------------------------------
  36. # the claiming script must be in the same directory as the netdata binary for web-based claiming to work
  37. run ln -s "${NETDATA_INSTALL_PATH}/bin/netdata-claim.sh" \
  38. "${NETDATA_INSTALL_PATH}/bin/srv/netdata-claim.sh" || exit 1
  39. # -----------------------------------------------------------------------------
  40. # copy the SSL/TLS configuration and certificates from the build system
  41. run cp -a /etc/ssl "${NETDATA_INSTALL_PATH}/share/ssl"
  42. # -----------------------------------------------------------------------------
  43. # remove the links to allow untaring the archive
  44. run rm "${NETDATA_INSTALL_PATH}/sbin" \
  45. "${NETDATA_INSTALL_PATH}/usr/bin" \
  46. "${NETDATA_INSTALL_PATH}/usr/sbin" \
  47. "${NETDATA_INSTALL_PATH}/usr/local"
  48. # -----------------------------------------------------------------------------
  49. # ensure required directories actually exist
  50. for dir in var/lib/netdata var/cache/netdata var/log/netdata ; do
  51. run mkdir -p "${NETDATA_INSTALL_PATH}/${dir}"
  52. run touch "${NETDATA_INSTALL_PATH}/${dir}/.keep"
  53. done
  54. # -----------------------------------------------------------------------------
  55. # create the makeself archive
  56. run sed "s|NETDATA_VERSION|${VERSION}|g" < "${NETDATA_MAKESELF_PATH}/makeself.lsm" > "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
  57. run "${NETDATA_MAKESELF_PATH}/makeself.sh" \
  58. --gzip \
  59. --complevel 9 \
  60. --notemp \
  61. --needroot \
  62. --target "${NETDATA_INSTALL_PATH}" \
  63. --header "${NETDATA_MAKESELF_PATH}/makeself-header.sh" \
  64. --lsm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp" \
  65. --license "${NETDATA_MAKESELF_PATH}/makeself-license.txt" \
  66. --help-header "${NETDATA_MAKESELF_PATH}/makeself-help-header.txt" \
  67. "${NETDATA_INSTALL_PATH}" \
  68. "${NETDATA_INSTALL_PATH}.gz.run" \
  69. "netdata, the real-time performance and health monitoring system" \
  70. ./system/post-installer.sh
  71. run rm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
  72. # -----------------------------------------------------------------------------
  73. # copy it to the netdata build dir
  74. FILE="netdata-${BUILDARCH}-${VERSION}.gz.run"
  75. run mkdir -p artifacts
  76. run mv "${NETDATA_INSTALL_PATH}.gz.run" "artifacts/${FILE}"
  77. [ -f "netdata-${BUILDARCH}-latest.gz.run" ] && rm "netdata-${BUILDARCH}-latest.gz.run"
  78. run cp "artifacts/${FILE}" "netdata-${BUILDARCH}-latest.gz.run"
  79. if [ "${BUILDARCH}" = "x86_64" ]; then
  80. [ -f "netdata-latest.gz.run" ] && rm "netdata-latest.gz.run"
  81. run cp "artifacts/${FILE}" "netdata-latest.gz.run"
  82. [ -f "artifacts/netdata-${VERSION}.gz.run" ] && rm "netdata-${VERSION}.gz.run"
  83. run cp "artifacts/${FILE}" "artifacts/netdata-${VERSION}.gz.run"
  84. fi
  85. # shellcheck disable=SC2015
  86. [ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
  87. echo >&2 "Self-extracting installer moved to 'artifacts/${FILE}'"