mirror of
https://github.com/duplicati/duplicati.git
synced 2025-11-28 11:30:24 +08:00
This updates Docker images to support UID/GID overrides, faling back to running as root. This also fixes the images to be actually allow executing the binaries as described in the README by adding them to the PATH environment variable. The README file was overhauled to fix some outdated content and include the new UID/GID override feature.
30 lines
No EOL
706 B
Bash
30 lines
No EOL
706 B
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
# Extract the command to run
|
|
CMD="$@"
|
|
|
|
if [ -z "$CMD" ]; then
|
|
echo "ERROR: No command specified to run."
|
|
exit 1
|
|
fi
|
|
|
|
# Create user/group and drop privileges if UID/GID are provided
|
|
if [[ -n "$UID" && -n "$GID" ]]; then
|
|
# Create group if it doesn't already exist
|
|
if ! getent group "$GID" >/dev/null; then
|
|
groupadd -g "$GID" duplicati
|
|
fi
|
|
|
|
# Create user if it doesn't already exist
|
|
if ! id -u "$UID" >/dev/null 2>&1; then
|
|
useradd -u "$UID" -g "$GID" -m -s /bin/bash duplicati
|
|
fi
|
|
|
|
# Set ownership on required paths
|
|
chown -R "$UID:$GID" /opt/duplicati /data || true
|
|
|
|
exec su duplicati -c "$(printf "%q " "$@")"
|
|
else
|
|
exec "$@"
|
|
fi |