You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

postinstall.cmake.in 1.3KB

123456789101112131415161718192021222324252627282930313233
  1. set(INIT_FLAVOR "@INIT_FLAVOR@")
  2. set(SECRET_FILE "@PROJECT_NAME@.secret")
  3. set(DD "@DD@")
  4. set(BASE64 "@BASE64@")
  5. set(INSSERV "@INSSERV@")
  6. if(INIT_FLAVOR AND NOT EXISTS "$ENV{DESTDIR}/etc/default/@PROJECT_NAME@")
  7. file(INSTALL "@CMAKE_CURRENT_SOURCE_DIR@/@PROJECT_NAME@.default" DESTINATION "/etc/default" RENAME "@PROJECT_NAME@")
  8. endif()
  9. if(INIT_FLAVOR STREQUAL "sysv")
  10. file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.init" TYPE PROGRAM DESTINATION "/etc/init.d" RENAME "@PROJECT_NAME@")
  11. if(INSSERV)
  12. execute_process(
  13. COMMAND ${INSSERV} -p "$ENV{DESTDIR}/etc/init.d" @PROJECT_NAME@
  14. )
  15. endif()
  16. elseif(INIT_FLAVOR STREQUAL "upstart")
  17. file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.upstart" DESTINATION "/etc/init" RENAME "@PROJECT_NAME@.conf")
  18. endif()
  19. if(DD AND BASE64 AND EXISTS "/dev/urandom" AND NOT EXISTS "$ENV{DESTDIR}/etc/${SECRET_FILE}")
  20. message(STATUS "Generating secret key")
  21. execute_process(
  22. COMMAND ${DD} if=/dev/urandom bs=18 count=1
  23. COMMAND ${BASE64} -w0
  24. OUTPUT_FILE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}"
  25. ERROR_QUIET
  26. OUTPUT_STRIP_TRAILING_WHITESPACE
  27. )
  28. file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}" DESTINATION "/etc" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
  29. file(REMOVE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}")
  30. endif()