docker-entrypoint.sh 702 B

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