您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

postinstall.cmake.in 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 AND NOT EXISTS "$ENV{DESTDIR}${CONFIG_DIR}/@PROJECT_NAME@")
  17. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.default" DESTINATION "${CONFIG_DIR}" RENAME "@PROJECT_NAME@")
  18. endif()
  19. if(INIT_FLAVOR STREQUAL "sysv-lsb")
  20. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.sysv-lsb" TYPE PROGRAM DESTINATION "${SYSCONF_DIR}/init.d" RENAME "@PROJECT_NAME@")
  21. if(INSSERV)
  22. execute_process(
  23. COMMAND ${INSSERV} -p "$ENV{DESTDIR}${SYSCONF_DIR}/init.d" @PROJECT_NAME@
  24. )
  25. endif()
  26. elseif(INIT_FLAVOR STREQUAL "sysv-redhat")
  27. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.sysv-redhat" TYPE PROGRAM DESTINATION "${SYSCONF_DIR}/init.d" RENAME "@PROJECT_NAME@")
  28. if(CHKCONFIG AND NOT "$ENV{DESTDIR}")
  29. execute_process(
  30. COMMAND ${CHKCONFIG} --add @PROJECT_NAME@
  31. )
  32. endif()
  33. elseif(INIT_FLAVOR STREQUAL "upstart")
  34. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.upstart" DESTINATION "${SYSCONF_DIR}/init" RENAME "@PROJECT_NAME@.conf")
  35. elseif(INIT_FLAVOR STREQUAL "systemd")
  36. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.systemd" DESTINATION "${SYSD_UNIT_DIR}" RENAME "@PROJECT_NAME@.service")
  37. endif()
  38. if(GENERATE_SRS_SECRET AND DD AND BASE64_ENCODE AND EXISTS "/dev/urandom" AND NOT EXISTS "$ENV{DESTDIR}${SYSCONF_DIR}/${SECRET_FILE}")
  39. message(STATUS "Generating secret key")
  40. execute_process(
  41. COMMAND ${DD} if=/dev/urandom bs=18 count=1
  42. COMMAND ${BASE64_ENCODE}
  43. OUTPUT_FILE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}"
  44. ERROR_QUIET
  45. OUTPUT_STRIP_TRAILING_WHITESPACE
  46. )
  47. file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}" DESTINATION "${SYSCONF_DIR}" RENAME "${SECRET_FILE}" PERMISSIONS OWNER_READ OWNER_WRITE)
  48. file(REMOVE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}")
  49. endif()