Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

postinstall.cmake.in 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. set(GENERATE_SRS_SECRET "@GENERATE_SRS_SECRET@")
  2. set(SYSCONF_DIR "@SYSCONF_DIR@")
  3. set(SYSD_UNIT_DIR "@SYSD_UNIT_DIR@")
  4. set(CHROOT_DIR "@CHROOT_DIR@")
  5. set(CONFIG_DIR "@CONFIG_DIR@")
  6. set(INIT_FLAVOR "@INIT_FLAVOR@")
  7. set(SECRET_FILE "@PROJECT_NAME@.secret")
  8. set(DD "@DD@")
  9. set(BASE64_ENCODE "@BASE64_ENCODE@")
  10. set(INSSERV "@INSSERV@")
  11. set(CHKCONFIG "@CHKCONFIG@")
  12. if(CHROOT_DIR AND NOT EXISTS "$ENV{DESTDIR}${CHROOT_DIR}")
  13. message(STATUS "Chroot jail: $ENV{DESTDIR}${CHROOT_DIR}")
  14. file(MAKE_DIRECTORY "$ENV{DESTDIR}${CHROOT_DIR}")
  15. endif()
  16. if(INIT_FLAVOR)
  17. if (NOT EXISTS "$ENV{DESTDIR}${CONFIG_DIR}/@PROJECT_NAME@")
  18. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.default" DESTINATION "${CONFIG_DIR}" RENAME "@PROJECT_NAME@")
  19. else()
  20. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.default" DESTINATION "${CONFIG_DIR}" RENAME "@PROJECT_NAME@.new")
  21. message(STATUS "")
  22. message(STATUS "*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*")
  23. message(STATUS "*!* ${CONFIG_DIR}/@PROJECT_NAME@ will NOT be overwritten!")
  24. message(STATUS "*!* Please note the changes from @PROJECT_NAME@.new in the same folder and")
  25. message(STATUS "*!* update your configuration accordinly.")
  26. message(STATUS "*!* See also README_UPGRADE.md for details")
  27. message(STATUS "*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*")
  28. message(STATUS "")
  29. endif()
  30. endif()
  31. if(INIT_FLAVOR STREQUAL "sysv-lsb")
  32. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.sysv-lsb" TYPE PROGRAM DESTINATION "${SYSCONF_DIR}/init.d" RENAME "@PROJECT_NAME@")
  33. if(INSSERV)
  34. execute_process(
  35. COMMAND ${INSSERV} -p "$ENV{DESTDIR}${SYSCONF_DIR}/init.d" @PROJECT_NAME@
  36. )
  37. endif()
  38. elseif(INIT_FLAVOR STREQUAL "sysv-redhat")
  39. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.sysv-redhat" TYPE PROGRAM DESTINATION "${SYSCONF_DIR}/init.d" RENAME "@PROJECT_NAME@")
  40. if(CHKCONFIG AND NOT "$ENV{DESTDIR}")
  41. execute_process(
  42. COMMAND ${CHKCONFIG} --add @PROJECT_NAME@
  43. )
  44. endif()
  45. elseif(INIT_FLAVOR STREQUAL "upstart")
  46. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.upstart" DESTINATION "${SYSCONF_DIR}/init" RENAME "@PROJECT_NAME@.conf")
  47. elseif(INIT_FLAVOR STREQUAL "systemd")
  48. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.systemd" DESTINATION "${SYSD_UNIT_DIR}" RENAME "@PROJECT_NAME@.service")
  49. endif()
  50. if(GENERATE_SRS_SECRET AND DD AND BASE64_ENCODE AND EXISTS "/dev/urandom" AND NOT EXISTS "$ENV{DESTDIR}${SYSCONF_DIR}/${SECRET_FILE}")
  51. message(STATUS "Generating secret key")
  52. execute_process(
  53. COMMAND ${DD} if=/dev/urandom bs=18 count=1
  54. COMMAND ${BASE64_ENCODE}
  55. OUTPUT_FILE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}"
  56. ERROR_QUIET
  57. OUTPUT_STRIP_TRAILING_WHITESPACE
  58. )
  59. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}" DESTINATION "${SYSCONF_DIR}" RENAME "${SECRET_FILE}" PERMISSIONS OWNER_READ OWNER_WRITE)
  60. file(REMOVE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}")
  61. endif()