Commit Graph

78 Commits

Author SHA1 Message Date
Alexander Aleksandrovič Klimov 1265eb76cc
icinga2.service: depend on icingadb-redis.service if any
to prevent its shutdown until we've written everything.
2022-01-31 17:03:34 +01:00
Alexander A. Klimov e98a7a9140 icinga2.service: add NotifyAccess=all
refs #7329
2021-06-01 18:07:42 +02:00
Benedikt Heine a71c105335 Run shellcheck over initscripts
Mainly quoting all variables
2020-12-27 16:57:23 +01:00
Benedikt Heine ebb2ec7e92 Use tabs for indentation
Except for the switch case, the script was written with tab indentation.
With tabstop of 4 spaces, the indentation in the switch case would make
sense, but I assume this is just a glitch of the editor.
2020-12-27 16:34:02 +01:00
Benedikt Heine d4251ea5ca Exit from script instead of subshell on missing user
When executing `false || (echo bad; exit 1)`, the call to `exit` won't
exit the script, it will only exit the subshell and the exit code will
be stored in the return code `$?`.

Since this is an error, we have to exit the script properly.
2020-12-27 16:29:37 +01:00
Alexander A. Klimov 2f0f2e8c35 prepare-dirs: combine mkdir and chmod 2020-06-08 15:14:29 +02:00
Michael Friedrich f8a82b5e28
Merge pull request #7183 from hlsolutions/bugfix/systemv-returncode
Fix System-V return codes according to LSB
2019-06-06 13:31:41 +02:00
Sascha Westermann a761adad8a Fix System-V return codes according to LSB
- "status"-calls use different exit codes, refer to http://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptact.html
- the "status"-call in "condrestart" returned an error if the daemon was not running: this has been fixed
2019-05-14 11:22:05 +02:00
Alexander A. Klimov fad2dc82ce Systemd: don't kill any running check plugins 2019-05-10 13:14:39 +02:00
Michael Friedrich 458f997a18 Replace Copyright header with a short version, part II 2019-02-25 15:09:36 +01:00
Michael Friedrich 6a4c5e6bcb Imitialize ICINGA2_ERROR_LOG inside the Systemd environment
The initscript uses a local default, which is not here for Systemd.
2018-11-13 14:02:03 +01:00
Schanz, Jens 2754175c6e fixes #6758
Add target network-online.target as requirement.
Service Icinga2 won't start before target is finally reached.
This prevents Icinga2 from failing if no entry for hostname.domain
is set in /etc/hosts
2018-11-09 13:17:08 +01:00
Michael Friedrich dea5ec614e icinga.com: Update CMakeLists.txt 2018-10-18 09:35:18 +02:00
Jean Flach 72cc41d14e
Merge pull request #6356 from sourcejedi/fix/systemd
Fix logging under systemd
2018-09-04 15:24:43 +02:00
Michael Friedrich 64305b4466 Fix using full path in prepare-dirs/safe-reload scripts
This won't be visible with packages and overridden paths,
just source builds which invoke the scripts manually.

refs #6506
2018-09-03 16:47:38 +02:00
Alan Jenkins a21166dcf8 Fix logging under systemd
icinga2.service used `-e ${ICINGA2_ERROR_LOG}`, but this is documented
as having no effect without `-d`.  Furthermore, icinga2 under systemd
unconditionally logged everything to the system log (but without setting
the log level etc), which contradicted the documentation.  (Issue #6339)

Stop icinga2 on systemd from logging to stdout - and hence the system log -
once it has finished starting up.  Just like when you start icinga2 from a
terminal using `-d`.  And just like -d, we stop logging fatal errors to
stderr, and instead write to the log file passed with `-e`.

As per docs, mainlog (icinga2.log) is already enabled by default.  And
pre-startup messages including config errors will still appear in the
system log.

This uses a new option --close-stdio, which has the same effect on logging as
--daemonize, but does not fork or call setsid().

For this purpose, I moved setsid() up and into Daemonize().

Consequence of that last point: if anyone is weird enough to specify a TTY
device file as the fatal error log (-e option), that will become icinga's
controlling terminal, which you generally don't want as a daemon.  This
makes it consistent with the existing behaviour for icinga mainlog.  For
this reason you're supposed to use O_NOCTTY in Linux daemons.  But I wasn't
sure where icinga would want to put the ugly `#ifdef _WIN32 ... #else ...`.
2018-08-25 10:21:06 +01:00
Markus Frosch 9fbc40615a Improve path handling in cmake and daemon 2018-08-07 14:10:26 +02:00
Jean Flach 383ca5011c Load functions first
refs #6449
2018-07-18 13:36:37 +02:00
Jean Flach 92056c592e Use . instead of source
fixes #6450
2018-07-18 13:35:27 +02:00
Michael Friedrich c4c6f2064d Revert "Fix obsolete parameter in Systemd script"
This reverts commit 592fb22c7f.

We have the problem that Systemd doesn't expand shell variables
into our environment.

During the upgrade cycle this would maybe render a wrong PID file
location, thus resulting in wrong 'safe-reload' behaviour.

This is only for a clean upgrade path from 2.8.x to 2.9.0,
the proper fix is to ensure that the sysconfig file is empty
and keep our own defaults, or modified from the user.

refs #6434
2018-07-17 14:10:26 +02:00
Jean Flach 44fae88d43 Update sysconfig read 2018-06-18 10:27:35 +02:00
Jean Flach 2b5ea38217 Fix sysconfig not bein handled correctly by sysvinit 2018-06-15 17:04:28 +02:00
Michael Friedrich 2dafcfa8a9 prepare-dirs: Ensure to always set proper run directory permissions
refs #6328
2018-06-06 14:32:26 +02:00
Michael Friedrich 592fb22c7f Fix obsolete parameter in Systemd script
refs #6328
2018-06-05 14:03:39 +02:00
Jean Flach ed4e008e79 Rework sysconfig file
The sysconfig file now only contains the defaults as comments, changes
made there are given to the init.d script, prepare-dirs, safe-reload and
Icinga 2 itself. If nothing is set in the sysconfig file (as is the
default as all lines are commented out) the defaults are used.

fixes #6255
2018-05-23 15:18:42 +02:00
Michael Friedrich a45dba15d3 Fix SysconfigFile detection for binary builds
It may happen that the variable is not properly initialized
and we'll have an empty string. Observed on macOS and inside
Docker.

refs #6215
2018-04-19 08:55:05 +02:00
Jean Flach ba882079be Don't use shell variables in sysconfig
fixes #6214
2018-04-13 13:03:12 +02:00
Jean Flach f7ec97abd8 Fix typo in prepare-dirs
refs #5850
2018-02-23 14:22:02 +01:00
Jean Flach 6ae376b7fd Add cli tool to send signals as Icinga user
fixes #5991
2018-02-20 14:16:43 +01:00
Jean Flach ba41d7f249 Get ICINGA2_USER and GROUP from sysconfig 2018-02-20 14:16:43 +01:00
Jean Flach 88f77f9f8d Fix prepare-dirs permission exploit
refs #5793
2018-02-20 14:16:43 +01:00
Jean Flach c418a9611e Add systemd watchdog and adjust reload behaviour 2018-01-19 16:52:36 +01:00
Jean Flach 1da6b2c883 Fix whitespaces in CMakeLists files
Uses 2 space indentation as standard
2018-01-19 09:19:40 +01:00
Michael Insel 158ae2188e Change copyright header for 2018 2018-01-02 12:08:55 +01:00
Markus Frosch c90dc34edb Improve documentation and Systemd config for TasksMax setting
This also disables setting a value by default.

Packaging should decide to install the config file:
`/etc/systemd/system/icinga2.service.d`

fixes #5611

Signed-off-by: Michael Friedrich <michael.friedrich@icinga.com>
2017-09-29 17:34:32 +02:00
Michael Friedrich 086e24f28a Ensure that the cache directory always is set and add a note to upgrading docs
Thanks @dgoetz
2017-09-22 09:31:42 +02:00
Michael Friedrich e188686ed4 Merge pull request #5392 from ekohl/cache-dir
Ensure the cache directory exists
2017-08-09 18:22:07 +02:00
Michael Friedrich 874e005284 Systemd: Add DefaultTasksMax=infinity to service file
This solves the problem with Systemd >= 226 and fork errors with
Icinga 2. Seen on SLES 11 SP2.

fixes #4918
2017-08-08 16:11:40 +02:00
Ewoud Kohl van Wijngaarden e83c43435d
Ensure the cache directory exists
As suggested in https://github.com/Icinga/icinga2/issues/4414
2017-07-01 13:59:58 +02:00
Dirk Goetz 7608acd0e2 improve systemd service file 2017-04-04 09:27:19 +02:00
Michael Friedrich 8842aa9b0c Add network requirement to init script
fixes #4921
2017-03-30 18:47:04 +02:00
Michael Friedrich b7caf0820d Ensure that *.icinga.com is used everywhere
fixes #13897
fixes #13277
2017-01-10 17:19:12 +01:00
Dirk Goetz bc06ff18e5 Mute chcon during safe-reload
Removes the error message on systems with SELinux enabled but without icinga2 policy.

fixes #11648
2016-08-15 13:33:47 +02:00
Berthold Cogel 47726d7701 Init script: condrestart should only restart a running service
fixes #11650

Signed-off-by: Michael Friedrich <michael.friedrich@netways.de>
2016-08-08 17:55:11 +02:00
Gunnar Beutner 256d936661 Increase systemd startup timeout
fixes #12237
2016-07-27 07:44:11 +02:00
Lee Clemens 984eaf5a1f Add network.target to unit file
Icinga2 fails with 'Cannot bind TCP socket for host',
if other services requiring network.target are not installed.

Signed-off-by: Jean Flach <jean-marcel.flach@netways.de>

fixes #10968
2016-01-14 10:11:38 +01:00
Gunnar Beutner 599929b0f6 Update copyright headers for 2016 2016-01-12 08:29:59 +01:00
Dirk Goetz c7c3cceba8 Only execute chcon if selinux is enabled and use full context
fixes #10773
2015-12-07 10:13:40 +01:00
Gunnar Beutner 9f44fadb65 Fix typo in prepare-dirs / safe-reload
fixes #10663
2015-11-18 20:18:04 +01:00
Gunnar Beutner 991bb0cd7e Don't use 'which' in the 'prepare-dirs' script
refs #10417
2015-11-06 17:43:08 +01:00