update(scripts): added a falcoctl systemd service.

Add a new dialog to choose whether to enable falcoctl feed.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
This commit is contained in:
Federico Di Pierro
2023-01-10 14:23:10 +01:00
committed by poiana
parent 2a886f7a3d
commit ffce069c96
9 changed files with 96 additions and 21 deletions

View File

@@ -16,32 +16,41 @@
#
chosen_driver=
enable_falcoctl=0
if [ $1 -eq 1 ]; then
if [ -x /usr/bin/dialog ]; then
# If dialog is installed, create a dialog to let users choose the correct driver for them
CHOICE=$(dialog --clear --backtitle "Choose your preferred driver" --title "Falco drivers" --menu "Choose one of the following options:" 15 40 5 \
CHOICE=$(dialog --clear --title "Falco drivers" --menu "Choose your preferred driver:" 12 40 5 \
1 "Don't start" \
2 "Kmod" \
3 "eBPF" \
4 "Modern eBPF" \
5 "Plugin" \
2>&1 >/dev/tty)
# When user presses cancel, go on as default (don't start)
if [ $? -eq 0 ]; then
case $CHOICE in
2)
chosen_driver="kmod"
;;
3)
chosen_driver="bpf"
;;
4)
chosen_driver="modern-bpf"
;;
5)
chosen_driver="plugin"
;;
esac
if [ -n "$chosen_driver" ]; then
CHOICE=$(dialog --clear --title "Falcoctl" --menu "Do you want to subscribe to automatic ruleset feed?" 10 40 2 \
1 "No" \
2 "Yes" \
2>&1 >/dev/tty)
case $CHOICE in
2)
chosen_driver="kmod"
;;
3)
chosen_driver="bpf"
;;
4)
chosen_driver="modern-bpf"
;;
5)
chosen_driver="plugin"
;;
2)
enable_falcoctl=1
;;
esac
fi
clear
@@ -78,6 +87,13 @@ if [ $1 -eq 1 ]; then
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.service':"
systemctl --system enable "falcoctl.service" || true
echo "[POST-INSTALL] Start 'falcoctl.service':"
systemctl --system start "falcoctl.service" || true
fi
fi
fi
@@ -90,6 +106,11 @@ if [ $1 -gt 1 ]; 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.service' condrestart:"
# restart falcoctl on upgrade if service is already running
systemctl --system condrestart "falcoctl.service" || true
fi
fi
fi
fi