From 33451cf0bc2a37edc708d5b5c2d388a13bcb21fe Mon Sep 17 00:00:00 2001 From: Federico Di Pierro Date: Mon, 27 Nov 2023 15:10:15 +0100 Subject: [PATCH] fix(scripts): fixed driver names for new falcoctl/Falco naming. But keep old systemd units names to avoid a breaking change. Signed-off-by: Federico Di Pierro --- scripts/debian/postinst.in | 22 +++++++++++++--------- scripts/rpm/postinstall.in | 24 ++++++++++++++---------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/scripts/debian/postinst.in b/scripts/debian/postinst.in index bc43a071..91e123e5 100755 --- a/scripts/debian/postinst.in +++ b/scripts/debian/postinst.in @@ -18,6 +18,7 @@ # chosen_driver= +chosen_unit= # Every time we call this script we want to stat from a clean state. echo "[POST-INSTALL] Disable all possible 'falco' services:" @@ -47,12 +48,15 @@ if [ "$1" = "configure" ]; then case $CHOICE in 2) chosen_driver="kmod" + chosen_unit="kmod" ;; 3) - chosen_driver="bpf" + chosen_driver="ebpf" + chosen_unit="bpf" ;; 4) - chosen_driver="modern-bpf" + chosen_driver="modern_ebpf" + chosen_unit="modern-bpf" ;; esac if [ -n "$chosen_driver" ]; then @@ -104,18 +108,18 @@ case "$chosen_driver" in echo "[POST-INSTALL] Call 'falcoctl driver install for kmod:" falcoctl driver install --download=false ;; - "bpf") - echo "[POST-INSTALL] Call 'falcoctl driver install for bpf':" + "ebpf") + echo "[POST-INSTALL] Call 'falcoctl driver install for ebpf':" falcoctl driver install ;; esac if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then - if [ -n "$chosen_driver" ]; then + if [ -n "$chosen_unit" ]; then # we do this in 2 steps because `enable --now` is not always supported - echo "[POST-INSTALL] Enable 'falco-$chosen_driver.service':" - systemctl --system enable "falco-$chosen_driver.service" || true - echo "[POST-INSTALL] Start 'falco-$chosen_driver.service':" - systemctl --system start "falco-$chosen_driver.service" || true + echo "[POST-INSTALL] Enable 'falco-$chosen_unit.service':" + systemctl --system enable "falco-$chosen_unit.service" || true + echo "[POST-INSTALL] Start 'falco-$chosen_unit.service':" + systemctl --system start "falco-$chosen_unit.service" || true fi fi diff --git a/scripts/rpm/postinstall.in b/scripts/rpm/postinstall.in index c89a9c15..0c68061a 100755 --- a/scripts/rpm/postinstall.in +++ b/scripts/rpm/postinstall.in @@ -17,6 +17,7 @@ # chosen_driver= +chosen_unit= # Every time we call this script we want to stat from a clean state. echo "[POST-INSTALL] Disable all possible enabled 'falco' service:" @@ -46,12 +47,15 @@ if [ $1 -ge 1 ]; then case $CHOICE in 2) chosen_driver="kmod" + chosen_unit="kmod" ;; 3) - chosen_driver="bpf" + chosen_driver="ebpf" + chosen_unit="bpf" ;; 4) - chosen_driver="modern-bpf" + chosen_driver="modern_ebpf" + chosen_unit="modern-bpf" ;; esac if [ -n "$chosen_driver" ]; then @@ -103,8 +107,8 @@ case "$chosen_driver" in echo "[POST-INSTALL] Call 'falcoctl driver install for kmod:" falcoctl driver install --download=false ;; - "bpf") - echo "[POST-INSTALL] Call 'falcoctl driver install for bpf':" + "ebpf") + echo "[POST-INSTALL] Call 'falcoctl driver install for ebpf':" falcoctl driver install ;; esac @@ -116,14 +120,14 @@ esac # systemd_post macro expands to # if postinst: # `systemd-update-helper install-system-units ` -%systemd_post "falco-$chosen_driver.service" +%systemd_post "falco-$chosen_unit.service" # post install/upgrade mirrored from .deb if [ $1 -ge 1 ]; then - if [ -n "$chosen_driver" ]; then - echo "[POST-INSTALL] Enable 'falco-$chosen_driver.service':" - systemctl --system enable "falco-$chosen_driver.service" || true - echo "[POST-INSTALL] Start 'falco-$chosen_driver.service':" - systemctl --system start "falco-$chosen_driver.service" || true + if [ -n "$chosen_unit" ]; then + echo "[POST-INSTALL] Enable 'falco-$chosen_unit.service':" + systemctl --system enable "falco-$chosen_unit.service" || true + echo "[POST-INSTALL] Start 'falco-$chosen_unit.service':" + systemctl --system start "falco-$chosen_unit.service" || true fi fi