fix(scripts): fixed some debian issues by directly using systemctl tool.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
This commit is contained in:
Federico Di Pierro
2022-11-09 15:02:22 +01:00
committed by poiana
parent cb20cf83ff
commit 01f4af480d
9 changed files with 34 additions and 51 deletions

View File

@@ -64,22 +64,16 @@ esac
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.
deb-systemd-helper unmask "falco@kmod.target" >/dev/null || true
deb-systemd-helper unmask "falco@bpf.target" >/dev/null || true
deb-systemd-helper unmask "falco@modern_bpf.target" >/dev/null || true
deb-systemd-helper unmask "falco@plugin.target" >/dev/null || true
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
if deb-systemd-helper --quiet was-enabled "falco@$chosen_driver.target"; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable "falco@$chosen_driver.target" >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state "falco@$chosen_driver.target" >/dev/null || true
fi
systemctl --system enable "falco@$chosen_driver.target" >/dev/null || true
systemctl --system start "falco@$chosen_driver.target" >/dev/null || true
fi
fi
@@ -87,12 +81,8 @@ if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-decon
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
if [ -n "$chosen_driver" ]; then
if [ -n "$2" ]; then
_dh_action=restart
else
_dh_action=start
fi
deb-systemd-invoke $_dh_action "falco@$chosen_driver.target" >/dev/null || true
# restart falco on upgrade if service is already running
/usr/bin/systemctl --system condrestart "falco@$chosen_driver.target" >/dev/null || true
fi
fi
fi

View File

@@ -27,22 +27,10 @@ fi
if [ "$1" = "remove" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper mask 'falco@kmod.target' >/dev/null || true
deb-systemd-helper mask 'falco@bpf.target' >/dev/null || true
deb-systemd-helper mask 'falco@modern_bpf.target' >/dev/null || true
deb-systemd-helper mask "falco@plugin.target" >/dev/null || true
fi
fi
if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge 'falco@kmod.target' >/dev/null || true
deb-systemd-helper unmask 'falco@kmod.target' >/dev/null || true
deb-systemd-helper purge 'falco@bpf.target' >/dev/null || true
deb-systemd-helper unmask 'falco@bpf.target' >/dev/null || true
deb-systemd-helper purge 'falco@modern_bpf.target' >/dev/null || true
deb-systemd-helper unmask 'falco@modern_bpf.target' >/dev/null || true
deb-systemd-helper purge 'falco@plugin.target' >/dev/null || true
deb-systemd-helper unmask 'falco@plugin.target' >/dev/null || true
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,10 +22,10 @@ set -e
# Currently running falco service uses the driver, so stop it before driver cleanup
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
deb-systemd-invoke stop 'falco@kmod.target' >/dev/null || true
deb-systemd-invoke stop 'falco@bpf.target' >/dev/null || true
deb-systemd-invoke stop 'falco@modern_bpf.target' >/dev/null || true
deb-systemd-invoke stop 'falco@plugin.target' >/dev/null || true
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
fi
case "$1" in

View File

@@ -70,10 +70,11 @@ esac
# post install mirrored from .deb
if [ $1 -eq 1 ]; then
# This will only remove masks created on package removal.
/usr/bin/systemctl --system unmask "falco@kmod.target" >/dev/null || true
/usr/bin/systemctl --system unmask "falco@bpf.target" >/dev/null || true
/usr/bin/systemctl --system unmask "falco@modern_bpf.target" >/dev/null || true
/usr/bin/systemctl --system unmask "falco@plugin.target" >/dev/null || true
/usr/bin/systemctl --system unmask "falco@.target" >/dev/null || true
/usr/bin/systemctl --system unmask "falco-kmod.service" >/dev/null || true
/usr/bin/systemctl --system unmask "falco-bpf.service" >/dev/null || true
/usr/bin/systemctl --system unmask "falco-modern_bpf.service" >/dev/null || true
/usr/bin/systemctl --system unmask "falco-plugin.service" >/dev/null || true
if [ -n "$chosen_driver" ]; then
# enable falco on installation
@@ -89,7 +90,6 @@ fi
if [ $1 -gt 1 ]; then
if [ -d /run/systemd/system ]; then
/usr/bin/systemctl --system daemon-reload >/dev/null || true
if [ -n "$chosen_driver" ]; then
# restart falco on upgrade if service is already running
/usr/bin/systemctl --system condrestart "falco@$chosen_driver.target" >/dev/null || true

View File

@@ -20,10 +20,11 @@ set -e
# post uninstall mirrored from .deb
if [ -d /run/systemd/system ] && [ "$1" = 0 ]; then
/usr/bin/systemctl --system daemon-reload >/dev/null || true
/usr/bin/systemctl --system mask 'falco@kmod.target' >/dev/null || true
/usr/bin/systemctl --system mask 'falco@bpf.target' >/dev/null || true
/usr/bin/systemctl --system mask 'falco@modern_bpf.target' >/dev/null || true
/usr/bin/systemctl --system mask 'falco@plugin.target' >/dev/null || true
/usr/bin/systemctl --system mask 'falco@.target' >/dev/null || true
/usr/bin/systemctl --system mask 'falco-kmod.service' >/dev/null || true
/usr/bin/systemctl --system mask 'falco-bpf.service' >/dev/null || true
/usr/bin/systemctl --system mask 'falco-modern_bpf.service' >/dev/null || true
/usr/bin/systemctl --system mask 'falco-plugin.service' >/dev/null || true
fi
# validate rpm macros by `rpm -qp --scripts <rpm>`

View File

@@ -3,6 +3,7 @@ Description=Falco: Container Native Runtime Security with ebpf
Documentation=https://falco.org/docs/
PartOf=falco@ebpf.target
Conflicts=falco-kmod.service
Conflicts=falco-modern_bpf.service
Conflicts=falco-plugin.service
[Service]

View File

@@ -4,7 +4,8 @@ Documentation=https://falco.org/docs/
After=falco-kmod-inject.service
Requires=falco-kmod-inject.service
PartOf=falco@kmod.target
Conflicts=falco-ebpf.service
Conflicts=falco-bpf.service
Conflicts=falco-modern_bpf.service
Conflicts=falco-plugin.service
[Service]

View File

@@ -3,6 +3,7 @@ Description=Falco: Container Native Runtime Security with ebpf
Documentation=https://falco.org/docs/
PartOf=falco@ebpf.target
Conflicts=falco-kmod.service
Conflicts=falco-bpf.service
Conflicts=falco-plugin.service
[Service]

View File

@@ -4,6 +4,7 @@ Documentation=https://falco.org/docs/
PartOf=falco@plugin.target
Conflicts=falco-kmod.service
Conflicts=falco-ebpf.service
Conflicts=falco-modern_bpf.service
[Service]
Type=simple