Add entrypoint sh

This commit is contained in:
theautomation 2022-12-21 15:46:43 +01:00
parent 6b843ad2b2
commit 6b973a2153
3 changed files with 38 additions and 2 deletions

View file

@ -54,6 +54,6 @@ HEALTHCHECK --interval=30s --retries=3 CMD curl --fail http://localhost:5232 ||
VOLUME /config /data
EXPOSE 5232
COPY docker-entrypoint.sh /usr/local/bin
ENTRYPOINT ["docker-entrypoint.sh"]
COPY ./src/entrypoint.sh /usr/local/bin
ENTRYPOINT ["entrypoint.sh"]
CMD ["radicale", "--config", "/config/config"]

View file

36
src/entrypoint.sh Normal file
View file

@ -0,0 +1,36 @@
#!/bin/sh
set -e
# Change uid/gid of radicale if vars specified
if [ -n "$UID" ] || [ -n "$GID" ]; then
if [ ! "$UID" = "$(id radicale -u)" ] || [ ! "$GID" = "$(id radicale -g)" ]; then
# Fail on read-only container
if grep -e "\s/\s.*\sro[\s,]" /proc/mounts >/dev/null; then
echo "You specified custom UID/GID (UID: $UID, GID: $GID)."
echo "UID/GID can only be changed when not running the container with --read-only."
echo "Please see the README.md for how to proceed and for explanations."
exit 1
fi
if [ -n "$UID" ]; then
usermod -o -u "$UID" radicale
fi
if [ -n "$GID" ]; then
groupmod -o -g "$GID" radicale
fi
fi
fi
# If requested and running as root, mutate the ownership of bind-mounts
if [ "$(id -u)" = "0" ] && [ "$TAKE_FILE_OWNERSHIP" = "true" ]; then
chown -R radicale:radicale /data
fi
# Run radicale as the "radicale" user or any other command if provided
if [ "$(id -u)" = "0" ] && [ "$1" = "radicale" ]; then
exec su-exec radicale "$@"
else
exec "$@"
fi