This commit is contained in:
2022-06-18 19:16:04 +02:00
parent 0403ccf7b4
commit 0713acf79a

View File

@@ -1,15 +1,15 @@
#!/bin/sh #!/bin/bash
set -e set -e
if [ "${1:0:1}" = '-' ]; then if [ "${1:0:1}" = '-' ]; then
set -- telegraf "$@" set -- telegraf "$@"
fi fi
if [ "$(id -u)" -ne 0 ]; then if [ $EUID -ne 0 ]; then
exec "$@" exec "$@"
else else
# Allow telegraf to send ICMP packets and bind to privliged ports # Allow telegraf to send ICMP packets and bind to privliged ports
setcap cap_net_raw,cap_net_bind_service+ep /usr/bin/telegraf || echo "Failed to set additional capabilities on /usr/bin/telegraf" setcap cap_net_raw,cap_net_bind_service+ep /usr/bin/telegraf || echo "Failed to set additional capabilities on /usr/bin/telegraf"
exec su-exec telegraf "$@" exec setpriv --reuid telegraf --init-groups "$@"
fi fi