scripts: remove falco.target and use require falcoctl with Wants=

Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
This commit is contained in:
Andrea Terzolo
2023-01-23 11:27:47 +01:00
committed by poiana
parent 9b7ab105d8
commit 7ed5f39da0
11 changed files with 70 additions and 79 deletions

View File

@@ -16,7 +16,21 @@
#
chosen_driver=
enable_falcoctl=0
echo "[POST-INSTALL] Disable all possible enabled 'falco' service:"
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
systemctl --system stop 'falcoctl-artifact-follow.service' || true
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
systemctl --system disable 'falcoctl-artifact-follow.service' || true
# unmask falcoctl if it was masked
systemctl --system unmask falcoctl-artifact-follow.service || true
if [ $1 -eq 1 ]; then
if [ -x /usr/bin/dialog ]; then
@@ -48,8 +62,9 @@ if [ $1 -eq 1 ]; then
2 "No" \
2>&1 >/dev/tty)
case $CHOICE in
1)
enable_falcoctl=1
2)
# we don't want falcoctl enabled by defualt, we mask it
systemctl --system mask falcoctl-artifact-follow.service || true
;;
esac
fi
@@ -59,6 +74,9 @@ fi
set -e
echo "[POST-INSTALL] Trigger deamon-reload:"
systemctl --system daemon-reload || true
# If needed, try to load/compile the driver through falco-driver-loader
case "$chosen_driver" in
"kmod")
@@ -80,36 +98,12 @@ esac
# `systemd-update-helper install-system-units <service>`
%systemd_post "falco-$chosen_driver.service"
# post install mirrored from .deb
if [ $1 -eq 1 ]; then
# 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 [ $enable_falcoctl -eq 1 ]; then
echo "[POST-INSTALL] Enable 'falcoctl-artifact-follow.service':"
systemctl --system enable "falcoctl-artifact-follow.service" || true
echo "[POST-INSTALL] Start 'falcoctl-artifact-follow.service':"
systemctl --system start "falcoctl-artifact-follow.service" || true
fi
fi
fi
# post upgrade mirrored from .deb
if [ $1 -gt 1 ]; then
if [ -d /run/systemd/system ]; then
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
systemctl --system condrestart "falco-$chosen_driver.service" || true
if [ $enable_falcoctl -eq 1 ]; then
echo "[POST-INSTALL] Trigger 'falcoctl-artifact-follow.service' condrestart:"
# restart falcoctl-artifact-follow on upgrade if service is already running
systemctl --system condrestart "falcoctl-artifact-follow.service" || true
fi
fi
fi
fi