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