syncthing/script/docker-entrypoint.sh
Jakob Borg a206366d10
docker: Fix handling of PCAP variable (fixes #8567) (#8568)
This correctly handles the absense of the PCAP environment variable,
which was broken in the previous change.
2022-10-02 08:50:27 +02:00

23 lines
579 B
Bash
Executable File

#!/bin/sh
set -eu
if [ "$(id -u)" = '0' ]; then
binary="$1"
if [ "${PCAP:-}" == "" ] ; then
# If Syncthing should have no extra capabilities, make sure to remove them
# from the binary. This will fail with an error if there are no
# capabilities to remove, hence the || true etc.
setcap -r "$binary" 2>/dev/null || true
else
# Set capabilities on the Syncthing binary before launching it.
setcap "$PCAP" "$binary"
fi
chown "${PUID}:${PGID}" "${HOME}" \
&& exec su-exec "${PUID}:${PGID}" \
env HOME="$HOME" "$@"
else
exec "$@"
fi