2019-05-18 06:43:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2020-07-14 09:38:59 +00:00
|
|
|
if [ "$(id -u)" = '0' ]; then
|
2022-09-26 11:39:41 +00:00
|
|
|
binary="$1"
|
2022-10-02 06:50:27 +00:00
|
|
|
if [ "${PCAP:-}" == "" ] ; then
|
2022-09-26 11:39:41 +00:00
|
|
|
# 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
|
|
|
|
|
2020-07-14 09:38:59 +00:00
|
|
|
chown "${PUID}:${PGID}" "${HOME}" \
|
|
|
|
&& exec su-exec "${PUID}:${PGID}" \
|
|
|
|
env HOME="$HOME" "$@"
|
|
|
|
else
|
|
|
|
exec "$@"
|
|
|
|
fi
|