diff --git a/CMakeLists.txt b/CMakeLists.txt index f3a0b525c8c..250d5745c05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1543,9 +1543,10 @@ if(DPKG_PROGRAM) ${PROJECT_SOURCE_DIR}/cpack/debian/conffiles ) + set(LDCONFIG_SCRIPT_CMDS "") if(FLB_RUN_LDCONFIG) set(LDCONFIG_DIR ${FLB_INSTALL_LIBDIR}) - file(WRITE ${PROJECT_BINARY_DIR}/scripts/postinst " + set(LDCONFIG_SCRIPT_CMDS " mkdir -p /etc/ld.so.conf.d echo \"${LDCONFIG_DIR}\" > /etc/ld.so.conf.d/libfluent-bit.conf ldconfig @@ -1554,9 +1555,19 @@ ldconfig rm -f -- /etc/ld.so.conf.d/libfluent-bit.conf ldconfig ") - set(CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/scripts/postinst;${PROJECT_BINARY_DIR}/scripts/prerm") + list(APPEND CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/scripts/postinst;${PROJECT_BINARY_DIR}/scripts/prerm") endif(FLB_RUN_LDCONFIG) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cpack/debian/postinst.in" + "${PROJECT_BINARY_DIR}/scripts/postinst" + ) + execute_process( + COMMAND "${CMAKE_COMMAND}" -E chmod +x + "${PROJECT_BINARY_DIR}/scripts/postinst" + ) + + list(APPEND CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/scripts/postinst") endif() # RPM Generation information diff --git a/cpack/debian/postinst.in b/cpack/debian/postinst.in new file mode 100644 index 00000000000..99ccdf4d099 --- /dev/null +++ b/cpack/debian/postinst.in @@ -0,0 +1,9 @@ +#!/bin/sh +set -e +@LDCONFIG_SCRIPT_CMDS@ +if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then + if [ -d /run/systemd/system ]; then + systemctl --system daemon-reload >/dev/null || true + systemctl try-restart @FLB_OUT_NAME@.service >/dev/null || true + fi +fi