12345678910111213141516171819202122232425262728293031323334 |
- set(GENERATE_SRS_SECRET "@GENERATE_SRS_SECRET@")
- set(INIT_FLAVOR "@INIT_FLAVOR@")
- set(SECRET_FILE "@PROJECT_NAME@.secret")
- set(DD "@DD@")
- set(BASE64 "@BASE64@")
- set(INSSERV "@INSSERV@")
-
- if(INIT_FLAVOR AND NOT EXISTS "$ENV{DESTDIR}/etc/default/@PROJECT_NAME@")
- file(INSTALL "@CMAKE_CURRENT_SOURCE_DIR@/@PROJECT_NAME@.default" DESTINATION "/etc/default" RENAME "@PROJECT_NAME@")
- endif()
-
- if(INIT_FLAVOR STREQUAL "sysv")
- file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.init" TYPE PROGRAM DESTINATION "/etc/init.d" RENAME "@PROJECT_NAME@")
- if(INSSERV)
- execute_process(
- COMMAND ${INSSERV} -p "$ENV{DESTDIR}/etc/init.d" @PROJECT_NAME@
- )
- endif()
- elseif(INIT_FLAVOR STREQUAL "upstart")
- file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.upstart" DESTINATION "/etc/init" RENAME "@PROJECT_NAME@.conf")
- endif()
-
- if(GENERATE_SRS_SECRET AND DD AND BASE64 AND EXISTS "/dev/urandom" AND NOT EXISTS "$ENV{DESTDIR}/etc/${SECRET_FILE}")
- message(STATUS "Generating secret key")
- execute_process(
- COMMAND ${DD} if=/dev/urandom bs=18 count=1
- COMMAND ${BASE64} -w0
- OUTPUT_FILE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}"
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}" DESTINATION "/etc" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
- file(REMOVE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}")
- endif()
|