浏览代码

Make sysconfig directory configurable

tags/1.2
Timo Röhling 10 年前
父节点
当前提交
ddd3612d30
共有 5 个文件被更改,包括 19 次插入17 次删除
  1. 6
    5
      CMakeLists.txt
  2. 7
    6
      postinstall.cmake.in
  3. 2
    2
      postsrsd.lsb_init.in
  4. 3
    3
      postsrsd.rh_init.in
  5. 1
    1
      postsrsd.upstart.in

+ 6
- 5
CMakeLists.txt 查看文件

@@ -5,7 +5,8 @@ option(GENERATE_SRS_SECRET "Generate a random SRS secret if none exists during i
5 5
 option(USE_APPARMOR "Enable AppArmor profile" OFF)
6 6
 
7 7
 set(CHROOT_DIR "${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}" CACHE PATH "Chroot jail for daemon")
8
-set(CONFIG_DIR "/etc/default" CACHE PATH "Location of configuration file")
8
+set(SYSCONF_DIR "/etc" CACHE PATH "Global system configuration folder")
9
+set(CONFIG_DIR "${SYSCONF_DIR}/default" CACHE PATH "Location of startup configuration file")
9 10
 set(DOC_DIR "share/doc/${PROJECT_NAME}" CACHE PATH "Path for documentation files")
10 11
 
11 12
 find_program(HELP2MAN help2man DOC "path to help2man executable")
@@ -15,13 +16,13 @@ find_program(INSSERV insserv DOC "path to insserv executable")
15 16
 find_program(CHKCONFIG chkconfig DOC "path to chkconfig executable")
16 17
 
17 18
 if(NOT DEFINED INIT_FLAVOR)
18
-    if(IS_DIRECTORY "/etc/init" AND EXISTS "/lib/init/upstart-job")
19
+    if(IS_DIRECTORY "${SYSCONF_DIR}/init" AND EXISTS "/lib/init/upstart-job")
19 20
         message(STATUS "Detected init flavor: upstart")
20 21
         set(INIT_FLAVOR "upstart" CACHE STRING "Init daemon of this system")
21
-    elseif(IS_DIRECTORY "/etc/init.d" AND EXISTS "/lib/lsb/init-functions")
22
+    elseif(IS_DIRECTORY "${SYSCONF_DIR}/init.d" AND EXISTS "/lib/lsb/init-functions")
22 23
         message(STATUS "Detected init flavor: sysv-lsb")
23 24
         set(INIT_FLAVOR "sysv-lsb" CACHE STRING "Init daemon of this system")
24
-    elseif(IS_DIRECTORY "/etc/init.d" AND EXISTS "/etc/init.d/functions")
25
+    elseif(IS_DIRECTORY "${SYSCONF_DIR}/init.d" AND EXISTS "${SYSCONF_DIR}/init.d/functions")
25 26
         message(STATUS "Detected init flavor: sysv-redhat")
26 27
         set(INIT_FLAVOR "sysv-redhat" CACHE STRING "Init daemon of this system")
27 28
     else()
@@ -54,7 +55,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.8 DESTINATION "share/m
54 55
 endif()
55 56
 
56 57
 if(USE_APPARMOR)
57
-	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.apparmor DESTINATION "/etc/apparmor.d" RENAME "${APPARMOR_PROFILE}")
58
+	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.apparmor DESTINATION "${SYSCONF_DIR}/apparmor.d" RENAME "${APPARMOR_PROFILE}")
58 59
 endif()
59 60
 
60 61
 install(TARGETS ${PROJECT_NAME} DESTINATION "sbin")

+ 7
- 6
postinstall.cmake.in 查看文件

@@ -1,4 +1,5 @@
1 1
 set(GENERATE_SRS_SECRET "@GENERATE_SRS_SECRET@")
2
+set(SYSCONF_DIR "@SYSCONF_DIR@")
2 3
 set(CHROOT_DIR "@CHROOT_DIR@")
3 4
 set(CONFIG_DIR "@CONFIG_DIR@")
4 5
 set(INIT_FLAVOR "@INIT_FLAVOR@")
@@ -18,24 +19,24 @@ if(INIT_FLAVOR AND NOT EXISTS "$ENV{DESTDIR}${CONFIG_DIR}/@PROJECT_NAME@")
18 19
 endif()
19 20
 
20 21
 if(INIT_FLAVOR STREQUAL "sysv-lsb")
21
-	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.lsb_init" TYPE PROGRAM DESTINATION "/etc/init.d" RENAME "@PROJECT_NAME@")
22
+	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.lsb_init" TYPE PROGRAM DESTINATION "${SYSCONF_DIR}/init.d" RENAME "@PROJECT_NAME@")
22 23
 	if(INSSERV)
23 24
 		execute_process(
24
-			COMMAND ${INSSERV} -p "$ENV{DESTDIR}/etc/init.d" @PROJECT_NAME@
25
+			COMMAND ${INSSERV} -p "$ENV{DESTDIR}${SYSCONF_DIR}/init.d" @PROJECT_NAME@
25 26
 		)
26 27
 	endif()
27 28
 elseif(INIT_FLAVOR STREQUAL "sysv-redhat")
28
-	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.rh_init" TYPE PROGRAM DESTINATION "/etc/init.d" RENAME "@PROJECT_NAME@")
29
+	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.rh_init" TYPE PROGRAM DESTINATION "${SYSCONF_DIR}/init.d" RENAME "@PROJECT_NAME@")
29 30
 	if(CHKCONFIG AND NOT "$ENV{DESTDIR}")
30 31
 		execute_process(
31 32
 			COMMAND ${CHKCONFIG} --add @PROJECT_NAME@
32 33
 		)
33 34
 	endif()
34 35
 elseif(INIT_FLAVOR STREQUAL "upstart")
35
-	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.upstart" DESTINATION "/etc/init" RENAME "@PROJECT_NAME@.conf")
36
+	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.upstart" DESTINATION "${SYSCONF_DIR}/init" RENAME "@PROJECT_NAME@.conf")
36 37
 endif()
37 38
 
38
-if(GENERATE_SRS_SECRET AND DD AND BASE64 AND EXISTS "/dev/urandom" AND NOT EXISTS "$ENV{DESTDIR}/etc/${SECRET_FILE}")
39
+if(GENERATE_SRS_SECRET AND DD AND BASE64 AND EXISTS "/dev/urandom" AND NOT EXISTS "$ENV{DESTDIR}${SYSCONF_DIR}/${SECRET_FILE}")
39 40
 	message(STATUS "Generating secret key")
40 41
 	execute_process(
41 42
 		COMMAND ${DD} if=/dev/urandom bs=18 count=1
@@ -44,6 +45,6 @@ if(GENERATE_SRS_SECRET AND DD AND BASE64 AND EXISTS "/dev/urandom" AND NOT EXIST
44 45
 		ERROR_QUIET
45 46
 		OUTPUT_STRIP_TRAILING_WHITESPACE
46 47
 	)
47
-file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}" DESTINATION "/etc" RENAME "${SECRET_FILE}" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
48
+file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}" DESTINATION "${SYSCONF_DIR}" RENAME "${SECRET_FILE}" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
48 49
 file(REMOVE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}")
49 50
 endif()

+ 2
- 2
postsrsd.lsb_init.in 查看文件

@@ -20,7 +20,7 @@ NAME=@PROJECT_NAME@
20 20
 DESC="Postfix Sender Rewriting Scheme daemon"
21 21
 
22 22
 PIDFILE=/var/run/$NAME.pid
23
-SCRIPTNAME=/etc/init.d/$NAME
23
+SCRIPTNAME=@SYSCONF_DIR@/init.d/$NAME
24 24
 
25 25
 # Gracefully exit if the package has been removed.
26 26
 test -x $DAEMON || exit 0
@@ -31,7 +31,7 @@ test -x $DAEMON || exit 0
31 31
 SRS_DOMAIN=`postconf -h mydomain || true`
32 32
 SRS_FORWARD_PORT=10001
33 33
 SRS_REVERSE_PORT=10002
34
-SRS_SECRET=/etc/@PROJECT_NAME@.secret
34
+SRS_SECRET=@SYSCONF_DIR@/@PROJECT_NAME@.secret
35 35
 RUN_AS=nobody
36 36
 CHROOT=@CHROOT_DIR@
37 37
 

+ 3
- 3
postsrsd.rh_init.in 查看文件

@@ -16,18 +16,18 @@ prog=@POSTSRSD@
16 16
 DESC="Postfix Sender Rewriting Scheme daemon"
17 17
 
18 18
 PIDFILE=/var/run/$NAME.pid
19
-SCRIPTNAME=/etc/init.d/$NAME
19
+SCRIPTNAME=@SYSCONF_DIR@/init.d/$NAME
20 20
 
21 21
 # Gracefully exit if the package has been removed.
22 22
 test -x $DAEMON || exit 0
23 23
 
24
-. /etc/init.d/functions
24
+. @SYSCONF_DIR@/init.d/functions
25 25
 
26 26
 # Default configuration
27 27
 SRS_DOMAIN=`postconf -h mydomain || true`
28 28
 SRS_FORWARD_PORT=10001
29 29
 SRS_REVERSE_PORT=10002
30
-SRS_SECRET=/etc/@PROJECT_NAME@.secret
30
+SRS_SECRET=@SYSCONF_DIR@/@PROJECT_NAME@.secret
31 31
 RUN_AS=nobody
32 32
 CHROOT=@CHROOT_DIR@
33 33
 

+ 1
- 1
postsrsd.upstart.in 查看文件

@@ -11,7 +11,7 @@ script
11 11
 	SRS_DOMAIN=`postconf -h mydomain || true`
12 12
 	SRS_FORWARD_PORT=10001
13 13
 	SRS_REVERSE_PORT=10002
14
-	SRS_SECRET=/etc/@PROJECT_NAME@.secret
14
+	SRS_SECRET=@SYSCONF_DIR@/@PROJECT_NAME@.secret
15 15
 	SRS_EXCLUDE_DOMAINS=
16 16
 	RUN_AS=nobody
17 17
 	CHROOT=@CHROOT_DIR@

正在加载...
取消
保存