From ca539ad5d09fdde2738f29902da1c5081a784cf4 Mon Sep 17 00:00:00 2001 From: joekohlsdorf Date: Mon, 20 Jun 2022 15:15:18 -0400 Subject: [PATCH] exit bash API-download script immediately if sensor is already running Makes the script do nothing if the sensor is already installed and running. This makes it more suitable to run from AWS SSM State Manager. --- .../bash/API-download/install.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Agent-Install-Examples/bash/API-download/install.sh b/Agent-Install-Examples/bash/API-download/install.sh index fe885c8..b34effe 100644 --- a/Agent-Install-Examples/bash/API-download/install.sh +++ b/Agent-Install-Examples/bash/API-download/install.sh @@ -25,12 +25,24 @@ main() { print_usage exit 1 fi + echo -n 'Falcon Sensor Install ... '; cs_sensor_install; echo '[ Ok ]' echo -n 'Falcon Sensor Register ... '; cs_sensor_register; echo '[ Ok ]' echo -n 'Falcon Sensor Restart ... '; cs_sensor_restart; echo '[ Ok ]' echo 'Falcon Sensor deployed successfully.' } +cs_sensor_exit_if_sensor_running() { + if type service >/dev/null 2>&1; then + service falcon-sensor status >/dev/null 2>&1 + elif type systemctl >/dev/null 2>&1; then + systemctl -q is-active falcon-sensor + fi + if [ $? -eq 0 ]; then + exit 0; + fi +} + cs_sensor_register() { /opt/CrowdStrike/falconctl -s -f --cid="${cs_falcon_cid}" } @@ -303,6 +315,8 @@ EOF } +cs_sensor_exit_if_sensor_running; + set -e