update: remove falco target

Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
This commit is contained in:
Andrea Terzolo
2022-11-11 12:54:08 +00:00
committed by poiana
parent 988256d930
commit ee08c4d3de
14 changed files with 69 additions and 95 deletions

View File

@@ -50,37 +50,32 @@ fi
# If needed, try to load/compile the driver through falco-driver-loader
case "$chosen_driver" in
"kmod")
echo "[POST-INSTALL] Call 'falco-driver-loader module':"
falco-driver-loader module
;;
"bpf")
echo "[POST-INSTALL] Call 'falco-driver-loader bpf':"
falco-driver-loader bpf
;;
esac
# Based off what debhelper dh_systemd_enable/13.3.4 would have added
# ref: https://www.debian.org/doc/manuals/debmake-doc/ch05.en.html#debhelper
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
# This will only remove masks created by d-s-h on package removal.
systemctl --system unmask "falco@.target" >/dev/null || true
systemctl --system unmask "falco-kmod.service" >/dev/null || true
systemctl --system unmask "falco-bpf.service" >/dev/null || true
systemctl --system unmask "falco-modern-bpf.service" >/dev/null || true
systemctl --system unmask "falco-plugin.service" >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if [ -n "$chosen_driver" ]; then
systemctl --system enable "falco@$chosen_driver.target" >/dev/null || true
systemctl --system start "falco@$chosen_driver.target" >/dev/null || true
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
fi
fi
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
echo "[POST-INSTALL] Trigger deamon-reload:"
systemctl --system daemon-reload || true
if [ -n "$chosen_driver" ]; then
echo "[POST-INSTALL] Trigger 'falco-$chosen_driver.service' condrestart:"
# restart falco on upgrade if service is already running
/usr/bin/systemctl --system condrestart "falco@$chosen_driver.target" >/dev/null || true
systemctl --system condrestart "falco-$chosen_driver.service" || true
fi
fi
fi

View File

@@ -22,15 +22,11 @@
set -e
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
systemctl --system daemon-reload >/dev/null || true
echo "[POST-REMOVE] Disable all Falco services:"
systemctl --system disable 'falco-kmod.service' || true
systemctl --system disable 'falco-bpf.service' || true
systemctl --system disable 'falco-modern-bpf.service' || true
systemctl --system disable 'falco-plugin.service' || true
echo "[POST-REMOVE] Trigger deamon-reload:"
systemctl --system daemon-reload || true
fi
if [ "$1" = "remove" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
systemctl --system mask 'falco@.target' >/dev/null || true
systemctl --system mask 'falco-kmod.service' >/dev/null || true
systemctl --system mask 'falco-bpf.service' >/dev/null || true
systemctl --system mask 'falco-modern-bpf.service' >/dev/null || true
systemctl --system mask "falco-plugin.service" >/dev/null || true
fi
fi

View File

@@ -22,14 +22,16 @@ set -e
# Currently running falco service uses the driver, so stop it before driver cleanup
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
systemctl --system stop 'falco@kmod.target' >/dev/null || true
systemctl --system stop 'falco@bpf.target' >/dev/null || true
systemctl --system stop 'falco@modern-bpf.target' >/dev/null || true
systemctl --system stop 'falco@plugin.target' >/dev/null || true
echo "[POST-REMOVE] Stop all Falco services:"
systemctl --system stop 'falco-kmod.service' || true
systemctl --system stop 'falco-bpf.service' || true
systemctl --system stop 'falco-modern-bpf.service' || true
systemctl --system stop 'falco-plugin.service' || true
fi
case "$1" in
remove|upgrade|deconfigure)
/usr/bin/falco-driver-loader --clean
echo "[POST-REMOVE] Call 'falco-driver-loader --clean:'"
falco-driver-loader --clean
;;
esac