fix(docker): default to auto for driver to be configured.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
This commit is contained in:
Federico Di Pierro 2024-04-16 08:52:02 +02:00 committed by poiana
parent fc7a451aed
commit 80a99b672f
3 changed files with 58 additions and 46 deletions

View File

@ -55,23 +55,17 @@ done
ENABLE_COMPILE="false" ENABLE_COMPILE="false"
ENABLE_DOWNLOAD="false" ENABLE_DOWNLOAD="false"
HTTP_INSECURE="false" HTTP_INSECURE="false"
has_driver= driver=
has_opts= has_opts=
while test $# -gt 0; do while test $# -gt 0; do
case "$1" in case "$1" in
auto|kmod|ebpf|modern_ebpf) auto|kmod|ebpf|modern_ebpf)
if [ -n "$has_driver" ]; then if [ -n "$driver" ]; then
>&2 echo "Only one driver per invocation" >&2 echo "Only one driver per invocation"
print_usage print_usage
exit 1 exit 1
else else
if [ "$opt" != "auto" ]; then driver=$1
/usr/bin/falcoctl driver config --type $opt
else
# Needed because we need to configure Falco to start with correct driver
/usr/bin/falcoctl driver config --type modern_ebpf --type ebpf --type kmod
fi
has_driver="true"
fi fi
;; ;;
-h|--help) -h|--help)
@ -93,11 +87,6 @@ while test $# -gt 0; do
--http-insecure) --http-insecure)
HTTP_INSECURE="true" HTTP_INSECURE="true"
;; ;;
--source-only)
>&2 echo "Support dropped in Falco 0.37.0."
print_usage
exit 1
;;
--print-env) --print-env)
/usr/bin/falcoctl driver printenv /usr/bin/falcoctl driver printenv
exit 0 exit 0
@ -116,9 +105,22 @@ while test $# -gt 0; do
shift shift
done done
# No opts passed, enable both compile and download
if [ -z "$has_opts" ]; then if [ -z "$has_opts" ]; then
ENABLE_COMPILE="true" ENABLE_COMPILE="true"
ENABLE_DOWNLOAD="true" ENABLE_DOWNLOAD="true"
fi fi
# Default value: auto
if [ -z "$driver" ]; then
driver="auto"
fi
if [ "$driver" != "auto" ]; then
/usr/bin/falcoctl driver config --type $driver
else
# Needed because we need to configure Falco to start with correct driver
/usr/bin/falcoctl driver config --type modern_ebpf --type ebpf --type kmod
fi
/usr/bin/falcoctl driver install --compile=$ENABLE_COMPILE --download=$ENABLE_DOWNLOAD --http-insecure=$HTTP_INSECURE --http-headers="$FALCOCTL_DRIVER_HTTP_HEADERS" /usr/bin/falcoctl driver install --compile=$ENABLE_COMPILE --download=$ENABLE_DOWNLOAD --http-insecure=$HTTP_INSECURE --http-headers="$FALCOCTL_DRIVER_HTTP_HEADERS"

View File

@ -57,25 +57,19 @@ done
ENABLE_COMPILE="false" ENABLE_COMPILE="false"
ENABLE_DOWNLOAD="false" ENABLE_DOWNLOAD="false"
HTTP_INSECURE="false" HTTP_INSECURE="false"
has_driver= driver=
has_opts= has_opts=
extra_args= extra_args=
while test $# -gt 0; do while test $# -gt 0; do
case "$1" in case "$1" in
auto|kmod|ebpf|modern_ebpf) auto|kmod|ebpf|modern_ebpf)
if [ -n "$has_driver" ]; then if [ -n "$driver" ]; then
>&2 echo "Only one driver per invocation" >&2 echo "Only one driver per invocation"
print_usage print_usage
exit 1 exit 1
else else
if [ "$opt" != "auto" ]; then driver=$1
/usr/bin/falcoctl driver config --type $opt
else
# Needed because we need to configure Falco to start with correct driver
/usr/bin/falcoctl driver config --type modern_ebpf --type ebpf --type kmod
fi
has_driver="true"
fi fi
;; ;;
-h|--help) -h|--help)
@ -123,9 +117,22 @@ while test $# -gt 0; do
shift shift
done done
# No opts passed, enable both compile and download
if [ -z "$has_opts" ]; then if [ -z "$has_opts" ]; then
ENABLE_COMPILE="true" ENABLE_COMPILE="true"
ENABLE_DOWNLOAD="true" ENABLE_DOWNLOAD="true"
fi fi
# Default value: auto
if [ -z "$driver" ]; then
driver="auto"
fi
if [ "$driver" != "auto" ]; then
/usr/bin/falcoctl driver config --type $driver
else
# Needed because we need to configure Falco to start with correct driver
/usr/bin/falcoctl driver config --type modern_ebpf --type ebpf --type kmod
fi
/usr/bin/falcoctl driver install --compile=$ENABLE_COMPILE --download=$ENABLE_DOWNLOAD --http-insecure=$HTTP_INSECURE --http-headers="$FALCOCTL_DRIVER_HTTP_HEADERS" $extra_args /usr/bin/falcoctl driver install --compile=$ENABLE_COMPILE --download=$ENABLE_DOWNLOAD --http-insecure=$HTTP_INSECURE --http-headers="$FALCOCTL_DRIVER_HTTP_HEADERS" $extra_args

View File

@ -62,24 +62,18 @@ if [[ -z "${SKIP_DRIVER_LOADER}" ]]; then
ENABLE_COMPILE="false" ENABLE_COMPILE="false"
ENABLE_DOWNLOAD="false" ENABLE_DOWNLOAD="false"
HTTP_INSECURE="false" HTTP_INSECURE="false"
has_driver= driver=
has_opts= has_opts=
for opt in "${falco_driver_loader_option_arr[@]}" for opt in "${falco_driver_loader_option_arr[@]}"
do do
case "$opt" in case "$opt" in
auto|kmod|ebpf|modern_ebpf) auto|kmod|ebpf|modern_ebpf)
if [ -n "$has_driver" ]; then if [ -n "$driver" ]; then
>&2 echo "Only one driver per invocation" >&2 echo "Only one driver per invocation"
print_usage print_usage
exit 1 exit 1
else else
if [ "$opt" != "auto" ]; then driver=$opt
/usr/bin/falcoctl driver config --type $opt
else
# Needed because we need to configure Falco to start with correct driver
/usr/bin/falcoctl driver config --type modern_ebpf --type ebpf --type kmod
fi
has_driver="true"
fi fi
;; ;;
-h|--help) -h|--help)
@ -101,31 +95,40 @@ if [[ -z "${SKIP_DRIVER_LOADER}" ]]; then
--http-insecure) --http-insecure)
HTTP_INSECURE="true" HTTP_INSECURE="true"
;; ;;
--source-only)
>&2 echo "Support dropped in Falco 0.37.0."
print_usage
exit 1
;;
--print-env) --print-env)
/usr/bin/falcoctl driver printenv /usr/bin/falcoctl driver printenv
exit 0 exit 0
;; ;;
--*) --*)
>&2 echo "Unknown option: $1" >&2 echo "Unknown option: $opt"
print_usage print_usage
exit 1 exit 1
;; ;;
*) *)
>&2 echo "Unknown driver: $1" >&2 echo "Unknown driver: $opt"
print_usage print_usage
exit 1 exit 1
;; ;;
esac esac
done done
# No opts passed, enable both compile and download
if [ -z "$has_opts" ]; then if [ -z "$has_opts" ]; then
ENABLE_COMPILE="true" ENABLE_COMPILE="true"
ENABLE_DOWNLOAD="true" ENABLE_DOWNLOAD="true"
fi fi
# Default value: auto
if [ -z "$driver" ]; then
driver="auto"
fi
if [ "$driver" != "auto" ]; then
/usr/bin/falcoctl driver config --type $driver
else
# Needed because we need to configure Falco to start with correct driver
/usr/bin/falcoctl driver config --type modern_ebpf --type ebpf --type kmod
fi
/usr/bin/falcoctl driver install --compile=$ENABLE_COMPILE --download=$ENABLE_DOWNLOAD --http-insecure=$HTTP_INSECURE --http-headers="$FALCOCTL_DRIVER_HTTP_HEADERS" /usr/bin/falcoctl driver install --compile=$ENABLE_COMPILE --download=$ENABLE_DOWNLOAD --http-insecure=$HTTP_INSECURE --http-headers="$FALCOCTL_DRIVER_HTTP_HEADERS"
fi fi