2019-05-17 23:43:53 -07:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2020-07-14 02:38:59 -07:00
|
|
|
if [ "$(id -u)" = '0' ]; then
|
2022-09-26 04:39:41 -07:00
|
|
|
binary="$1"
|
2022-10-01 23:50:27 -07:00
|
|
|
if [ "${PCAP:-}" == "" ] ; then
|
2022-09-26 04:39:41 -07: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
|
|
|
|
|
2023-10-06 19:12:07 -07:00
|
|
|
# Chown may fail, which may cause us to be unable to start; but maybe
|
|
|
|
# it'll work anyway, so we let the error slide.
|
|
|
|
chown "${PUID}:${PGID}" "${HOME}" || true
|
|
|
|
exec su-exec "${PUID}:${PGID}" \
|
2020-07-14 02:38:59 -07:00
|
|
|
env HOME="$HOME" "$@"
|
|
|
|
else
|
|
|
|
exec "$@"
|
|
|
|
fi
|