mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 17:24:04 +00:00
c4dfb66d84
Add support for setting umask value in the Docker `entrypoint.sh` script. This is useful when not syncing permissions and working with groups, and needing umask values like `002` instead of `022`.
27 lines
737 B
Bash
Executable File
27 lines
737 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
[ -n "${UMASK:-}" ] && umask "$UMASK"
|
|
|
|
if [ "$(id -u)" = '0' ]; then
|
|
binary="$1"
|
|
if [ -z "${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 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}" \
|
|
env HOME="$HOME" "$@"
|
|
else
|
|
exec "$@"
|
|
fi
|