forked from tomsquest/docker-radicale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·36 lines (30 loc) · 1.1 KB
/
docker-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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