CrowdStrike / falcon-scripts

Scripts to streamline the deployment and use of the CrowdStrike Falcon sensor
The Unlicense
127 stars 79 forks source link

falcon-linux-install.sh: fix ordering of restart type #286

Closed EricHorst closed 2 months ago

EricHorst commented 2 months ago

On most (or all) platforms that use systemd, a SysVinit compatibility script is provided at /usr/sbin/service. When one runs /usr/sbin/service it works but issues a warning like "redirecting to systemctl".

The falcon-linux-install.sh script, tests for service first, and then systemctl. Because of the compatibiliity script, the service conditional always matches, even on modern systemd systems. Thus systemd systems always use the compatibility script and always issue the "redirecting to systemctl" message. It is more ideal to just use systemctl on a systemd system.

This patch reverses the tests, checking systemctl first, which is obviously the most common case and then checking for service second. On systemd-based systems this will result in the best behaviour, using systemctl and on older sysVinit systems the behaviour is unchanged.

redhatrises commented 2 months ago

Lgtm