Browse Source

Make sysconfig directory configurable

tags/1.2
Timo Röhling 10 years ago
parent
commit
ddd3612d30
5 changed files with 19 additions and 17 deletions
  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 View File

5
 option(USE_APPARMOR "Enable AppArmor profile" OFF)
5
 option(USE_APPARMOR "Enable AppArmor profile" OFF)
6
 
6
 
7
 set(CHROOT_DIR "${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}" CACHE PATH "Chroot jail for daemon")
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
 set(DOC_DIR "share/doc/${PROJECT_NAME}" CACHE PATH "Path for documentation files")
10
 set(DOC_DIR "share/doc/${PROJECT_NAME}" CACHE PATH "Path for documentation files")
10
 
11
 
11
 find_program(HELP2MAN help2man DOC "path to help2man executable")
12
 find_program(HELP2MAN help2man DOC "path to help2man executable")
15
 find_program(CHKCONFIG chkconfig DOC "path to chkconfig executable")
16
 find_program(CHKCONFIG chkconfig DOC "path to chkconfig executable")
16
 
17
 
17
 if(NOT DEFINED INIT_FLAVOR)
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
         message(STATUS "Detected init flavor: upstart")
20
         message(STATUS "Detected init flavor: upstart")
20
         set(INIT_FLAVOR "upstart" CACHE STRING "Init daemon of this system")
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
         message(STATUS "Detected init flavor: sysv-lsb")
23
         message(STATUS "Detected init flavor: sysv-lsb")
23
         set(INIT_FLAVOR "sysv-lsb" CACHE STRING "Init daemon of this system")
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
         message(STATUS "Detected init flavor: sysv-redhat")
26
         message(STATUS "Detected init flavor: sysv-redhat")
26
         set(INIT_FLAVOR "sysv-redhat" CACHE STRING "Init daemon of this system")
27
         set(INIT_FLAVOR "sysv-redhat" CACHE STRING "Init daemon of this system")
27
     else()
28
     else()
54
 endif()
55
 endif()
55
 
56
 
56
 if(USE_APPARMOR)
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
 endif()
59
 endif()
59
 
60
 
60
 install(TARGETS ${PROJECT_NAME} DESTINATION "sbin")
61
 install(TARGETS ${PROJECT_NAME} DESTINATION "sbin")

+ 7
- 6
postinstall.cmake.in View File

1
 set(GENERATE_SRS_SECRET "@GENERATE_SRS_SECRET@")
1
 set(GENERATE_SRS_SECRET "@GENERATE_SRS_SECRET@")
2
+set(SYSCONF_DIR "@SYSCONF_DIR@")
2
 set(CHROOT_DIR "@CHROOT_DIR@")
3
 set(CHROOT_DIR "@CHROOT_DIR@")
3
 set(CONFIG_DIR "@CONFIG_DIR@")
4
 set(CONFIG_DIR "@CONFIG_DIR@")
4
 set(INIT_FLAVOR "@INIT_FLAVOR@")
5
 set(INIT_FLAVOR "@INIT_FLAVOR@")
18
 endif()
19
 endif()
19
 
20
 
20
 if(INIT_FLAVOR STREQUAL "sysv-lsb")
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
 	if(INSSERV)
23
 	if(INSSERV)
23
 		execute_process(
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
 	endif()
27
 	endif()
27
 elseif(INIT_FLAVOR STREQUAL "sysv-redhat")
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
 	if(CHKCONFIG AND NOT "$ENV{DESTDIR}")
30
 	if(CHKCONFIG AND NOT "$ENV{DESTDIR}")
30
 		execute_process(
31
 		execute_process(
31
 			COMMAND ${CHKCONFIG} --add @PROJECT_NAME@
32
 			COMMAND ${CHKCONFIG} --add @PROJECT_NAME@
32
 		)
33
 		)
33
 	endif()
34
 	endif()
34
 elseif(INIT_FLAVOR STREQUAL "upstart")
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
 endif()
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
 	message(STATUS "Generating secret key")
40
 	message(STATUS "Generating secret key")
40
 	execute_process(
41
 	execute_process(
41
 		COMMAND ${DD} if=/dev/urandom bs=18 count=1
42
 		COMMAND ${DD} if=/dev/urandom bs=18 count=1
44
 		ERROR_QUIET
45
 		ERROR_QUIET
45
 		OUTPUT_STRIP_TRAILING_WHITESPACE
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
 file(REMOVE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}")
49
 file(REMOVE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}")
49
 endif()
50
 endif()

+ 2
- 2
postsrsd.lsb_init.in View File

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

+ 3
- 3
postsrsd.rh_init.in View File

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

+ 1
- 1
postsrsd.upstart.in View File

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

Loading…
Cancel
Save