Move the sysdefines.conf file to /etc/sysconfig.

As /etc/sysconfig is distro specific, the filename used can be configured via the CMake parameter
ICINGA2_SYSCONFIGFILE

Refs #4794
This commit is contained in:
Gerd von Egidy 2014-06-15 19:47:27 +02:00
parent 83528f660f
commit dd9b7bcd73
6 changed files with 24 additions and 20 deletions

View File

@ -76,10 +76,17 @@ else()
endif() endif()
if(NOT WIN32) if(NOT WIN32)
configure_file(icinga2/sysdefines.conf.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga2/sysdefines.conf @ONLY) if(NOT DEFINED ICINGA2_SYSCONFIGFILE)
set(ICINGA2_SYSCONFIGFILE "${CMAKE_INSTALL_SYSCONFDIR}/sysconfig/icinga2" CACHE PATH "where to store configuation for the init system, defaults to /etc/sysconfig/icinga2")
endif()
configure_file(initsystem/icinga2.sysconfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2.sysconfig @ONLY)
get_filename_component(ICINGA2_SYSCONFIGFILE_NAME ${ICINGA2_SYSCONFIGFILE} NAME)
get_filename_component(ICINGA2_SYSCONFIGFILE_DIR ${ICINGA2_SYSCONFIGFILE} PATH)
install( install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/icinga2/sysdefines.conf FILES ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2.sysconfig
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/icinga2 DESTINATION ${ICINGA2_SYSCONFIGFILE_DIR}
RENAME ${ICINGA2_SYSCONFIGFILE_NAME}
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
) )

View File

@ -4,11 +4,11 @@
# #
# load system specific defines # load system specific defines
SYSDEFFILE=$1 SYSCONFIGFILE=$1
if [ -f "$SYSDEFFILE" ]; then if [ -f "$SYSCONFIGFILE" ]; then
. $SYSDEFFILE . $SYSCONFIGFILE
else else
echo "Error: You need to supply the path to the Icinga2 sysdefines.conf as parameter." echo "Error: You need to supply the path to the Icinga2 sysconfig file as parameter."
exit 1 exit 1
fi fi

View File

@ -16,11 +16,11 @@
### END INIT INFO ### END INIT INFO
# load system specific defines # load system specific defines
SYSDEFFILE=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf SYSCONFIGFILE=@ICINGA2_SYSCONFIGFILE@
if [ -f $SYSDEFFILE ]; then if [ -f $SYSCONFIGFILE ]; then
. $SYSDEFFILE . $SYSCONFIGFILE
else else
echo "Can't load system specific defines from $SYSDEFFILE." echo "Can't load system specific defines from $SYSCONFIGFILE."
exit 1 exit 1
fi fi
@ -39,17 +39,14 @@ elif [ -f /etc/init.d/functions ]; then
fi fi
# Load extra environment variables # Load extra environment variables
if [ -f /etc/sysconfig/icinga ]; then if [ -f /etc/default/icinga2 ]; then
. /etc/sysconfig/icinga . /etc/default/icinga2
fi
if [ -f /etc/default/icinga ]; then
. /etc/default/icinga
fi fi
# Start Icinga 2 # Start Icinga 2
start() { start() {
printf "Starting Icinga 2: " printf "Starting Icinga 2: "
@CMAKE_INSTALL_FULL_SBINDIR@/icinga2-prepare-dirs $SYSDEFFILE @CMAKE_INSTALL_FULL_SBINDIR@/icinga2-prepare-dirs $SYSCONFIGFILE
if ! $DAEMON -c $ICINGA2_CONFIG_FILE -d -e $ICINGA2_ERROR_LOG -u $ICINGA2_USER -g $ICINGA2_GROUP > $ICINGA2_STARTUP_LOG 2>&1; then if ! $DAEMON -c $ICINGA2_CONFIG_FILE -d -e $ICINGA2_ERROR_LOG -u $ICINGA2_USER -g $ICINGA2_GROUP > $ICINGA2_STARTUP_LOG 2>&1; then
echo "Error starting Icinga. Check '$ICINGA2_STARTUP_LOG' for details." echo "Error starting Icinga. Check '$ICINGA2_STARTUP_LOG' for details."

View File

@ -4,8 +4,8 @@ After=syslog.target postgresql.service mariadb.service
[Service] [Service]
Type=forking Type=forking
EnvironmentFile=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf EnvironmentFile=@ICINGA2_SYSCONFIGFILE@
ExecStartPre=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2-prepare-dirs @CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/sysdefines.conf ExecStartPre=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2-prepare-dirs @ICINGA2_SYSCONFIGFILE@
ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2 -c ${ICINGA2_CONFIG_FILE} -d -e ${ICINGA2_ERROR_LOG} -u ${ICINGA2_USER} -g ${ICINGA2_GROUP} ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2 -c ${ICINGA2_CONFIG_FILE} -d -e ${ICINGA2_ERROR_LOG} -u ${ICINGA2_USER} -g ${ICINGA2_GROUP}
PIDFile=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/run/icinga2/icinga2.pid PIDFile=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/run/icinga2/icinga2.pid
ExecReload=/bin/kill -HUP $MAINPID ExecReload=/bin/kill -HUP $MAINPID

View File

@ -458,13 +458,13 @@ exit 0
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/sysdefines.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/*.conf %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/*.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/localhost/*.conf %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/localhost/*.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/* %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
%config(noreplace) %{_sysconfdir}/%{name}/scripts/* %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%{_sbindir}/%{name} %{_sbindir}/%{name}
%{_bindir}/%{name}-build-ca %{_bindir}/%{name}-build-ca
%{_bindir}/%{name}-build-key %{_bindir}/%{name}-build-key