docker-entrypoint.sh 737 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. set -eu
  3. [ -n "${UMASK:-}" ] && umask "$UMASK"
  4. if [ "$(id -u)" = '0' ]; then
  5. binary="$1"
  6. if [ -z "${PCAP:-}" ]; then
  7. # If Syncthing should have no extra capabilities, make sure to remove them
  8. # from the binary. This will fail with an error if there are no
  9. # capabilities to remove, hence the || true etc.
  10. setcap -r "$binary" 2>/dev/null || true
  11. else
  12. # Set capabilities on the Syncthing binary before launching it.
  13. setcap "$PCAP" "$binary"
  14. fi
  15. # Chown may fail, which may cause us to be unable to start; but maybe
  16. # it'll work anyway, so we let the error slide.
  17. chown "${PUID}:${PGID}" "${HOME}" || true
  18. exec su-exec "${PUID}:${PGID}" \
  19. env HOME="$HOME" "$@"
  20. else
  21. exec "$@"
  22. fi