Browse Source

Initial systemd support

tags/1.2
bjoe2k4 10 years ago
parent
commit
b4bcb77ca7
3 changed files with 20 additions and 1 deletions
  1. 5
    1
      CMakeLists.txt
  2. 2
    0
      postinstall.cmake.in
  3. 13
    0
      postsrsd.service.in

+ 5
- 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)
65
 configure_file(postinstall.cmake.in postinstall.cmake @ONLY)
69
 configure_file(postinstall.cmake.in postinstall.cmake @ONLY)
66
 
70
 
67
 if(HELP2MAN)
71
 if(HELP2MAN)

+ 2
- 0
postinstall.cmake.in View File

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}")

+ 13
- 0
postsrsd.service.in View File

1
+Description=PostSRSd Daemon
2
+After=network.target
3
+
4
+[Service]
5
+Type=simple
6
+Environment=SRS_DOMAIN=localhost.localdomain SRS_FORWARD_PORT=10001 SRS_REVERSE_PORT=10002 SRS_SECRET=@SYSCONF_DIR@/@PROJECT_NAME@.secret
7
+Environment=SRS_EXCLUDE_DOMAINS= RUN_AS=nobody CHROOT=@CHROOT_DIR@
8
+EnvironmentFile=-@CONFIG_DIR@/@PROJECT_NAME@
9
+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}
10
+Restart=always
11
+
12
+[Install]
13
+WantedBy=multi-user.target

Loading…
Cancel
Save