Browse Source

Merge initial systemd support from bjoe2k4

tags/1.2
Timo Röhling 10 years ago
parent
commit
fefe8efceb
4 changed files with 25 additions and 3 deletions
  1. 7
    1
      CMakeLists.txt
  2. 3
    1
      postinstall.cmake.in
  3. 1
    1
      postsrsd.default.in
  4. 14
    0
      postsrsd.service.in

+ 7
- 1
CMakeLists.txt View File

34
 endif()
34
 endif()
35
 
35
 
36
 if(NOT DEFINED INIT_FLAVOR)
36
 if(NOT DEFINED INIT_FLAVOR)
37
-    if(IS_DIRECTORY "${SYSCONF_DIR}/init" AND EXISTS "/lib/init/upstart-job")
37
+	if(IS_DIRECTORY "${SYSCONF_DIR}/systemd" AND EXISTS "/usr/lib/systemd/systemd")
38
+        message(STATUS "Detected init flavor: systemd")
39
+        set(INIT_FLAVOR "systemd" CACHE STRING "Init daemon of this system")
40
+    elseif(IS_DIRECTORY "${SYSCONF_DIR}/init" AND EXISTS "/lib/init/upstart-job")
38
         message(STATUS "Detected init flavor: upstart")
41
         message(STATUS "Detected init flavor: upstart")
39
         set(INIT_FLAVOR "upstart" CACHE STRING "Init daemon of this system")
42
         set(INIT_FLAVOR "upstart" CACHE STRING "Init daemon of this system")
40
     elseif(IS_DIRECTORY "${SYSCONF_DIR}/init.d" AND EXISTS "${SYSCONF_DIR}/init.d/functions")
43
     elseif(IS_DIRECTORY "${SYSCONF_DIR}/init.d" AND EXISTS "${SYSCONF_DIR}/init.d/functions")
62
 configure_file(${PROJECT_NAME}.rh_init.in ${PROJECT_NAME}.rh_init @ONLY)
65
 configure_file(${PROJECT_NAME}.rh_init.in ${PROJECT_NAME}.rh_init @ONLY)
63
 configure_file(${PROJECT_NAME}.upstart.in ${PROJECT_NAME}.upstart @ONLY)
66
 configure_file(${PROJECT_NAME}.upstart.in ${PROJECT_NAME}.upstart @ONLY)
64
 configure_file(${PROJECT_NAME}.apparmor.in ${PROJECT_NAME}.apparmor @ONLY)
67
 configure_file(${PROJECT_NAME}.apparmor.in ${PROJECT_NAME}.apparmor @ONLY)
68
+configure_file(${PROJECT_NAME}.service.in ${PROJECT_NAME}.service @ONLY)
69
+configure_file(${PROJECT_NAME}.default.in ${PROJECT_NAME}.default @ONLY)
70
+
65
 configure_file(postinstall.cmake.in postinstall.cmake @ONLY)
71
 configure_file(postinstall.cmake.in postinstall.cmake @ONLY)
66
 
72
 
67
 if(HELP2MAN)
73
 if(HELP2MAN)

+ 3
- 1
postinstall.cmake.in View File

15
 endif()
15
 endif()
16
 
16
 
17
 if(INIT_FLAVOR AND NOT EXISTS "$ENV{DESTDIR}${CONFIG_DIR}/@PROJECT_NAME@")
17
 if(INIT_FLAVOR AND NOT EXISTS "$ENV{DESTDIR}${CONFIG_DIR}/@PROJECT_NAME@")
18
-	file(INSTALL FILES "@CMAKE_CURRENT_SOURCE_DIR@/@PROJECT_NAME@.default" DESTINATION "${CONFIG_DIR}" RENAME "@PROJECT_NAME@")
18
+	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.default" DESTINATION "${CONFIG_DIR}" RENAME "@PROJECT_NAME@")
19
 endif()
19
 endif()
20
 
20
 
21
 if(INIT_FLAVOR STREQUAL "sysv-lsb")
21
 if(INIT_FLAVOR STREQUAL "sysv-lsb")
34
 	endif()
34
 	endif()
35
 elseif(INIT_FLAVOR STREQUAL "upstart")
35
 elseif(INIT_FLAVOR STREQUAL "upstart")
36
 	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.upstart" DESTINATION "${SYSCONF_DIR}/init" RENAME "@PROJECT_NAME@.conf")
36
 	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.upstart" DESTINATION "${SYSCONF_DIR}/init" RENAME "@PROJECT_NAME@.conf")
37
+elseif(INIT_FLAVOR STREQUAL "systemd")
38
+	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.service" DESTINATION "${SYSCONF_DIR}/systemd/system" RENAME "@PROJECT_NAME@.service")
37
 endif()
39
 endif()
38
 
40
 
39
 if(GENERATE_SRS_SECRET AND DD AND BASE64 AND EXISTS "/dev/urandom" AND NOT EXISTS "$ENV{DESTDIR}${SYSCONF_DIR}/${SECRET_FILE}")
41
 if(GENERATE_SRS_SECRET AND DD AND BASE64 AND EXISTS "/dev/urandom" AND NOT EXISTS "$ENV{DESTDIR}${SYSCONF_DIR}/${SECRET_FILE}")

postsrsd.default → postsrsd.default.in View File

17
 # When postsrsd is installed for the first time, a random secret is generated
17
 # When postsrsd is installed for the first time, a random secret is generated
18
 # and stored in /etc/postsrsd.secret. For most installations, that's just fine.
18
 # and stored in /etc/postsrsd.secret. For most installations, that's just fine.
19
 #
19
 #
20
-#SRS_SECRET=/etc/postsrsd.secret
20
+SRS_SECRET=@SYSCONF_DIR@/@PROJECT_NAME@.secret
21
 
21
 
22
 # Local ports for TCP list.
22
 # Local ports for TCP list.
23
 # These ports are used to bind the TCP list for postfix. If you change
23
 # These ports are used to bind the TCP list for postfix. If you change

+ 14
- 0
postsrsd.service.in View File

1
+[Unit]
2
+Description=PostSRSd Daemon
3
+After=network.target
4
+
5
+[Service]
6
+Type=simple
7
+Environment=SRS_DOMAIN=localhost.localdomain SRS_FORWARD_PORT=10001 SRS_REVERSE_PORT=10002 SRS_SECRET=@SYSCONF_DIR@/@PROJECT_NAME@.secret
8
+Environment=SRS_EXCLUDE_DOMAINS= RUN_AS=nobody CHROOT=@CHROOT_DIR@
9
+EnvironmentFile=-@CONFIG_DIR@/@PROJECT_NAME@
10
+ExecStart=@CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@ -4 -f${SRS_FORWARD_PORT} -r${SRS_REVERSE_PORT} -d${SRS_DOMAIN} -s${SRS_SECRET} -u${RUN_AS} -c${CHROOT} -X${SRS_EXCLUDE_DOMAINS}
11
+Restart=always
12
+
13
+[Install]
14
+WantedBy=multi-user.target

Loading…
Cancel
Save