2026-02-12 09:57:33 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
# Fix ownership of mounted volumes.
|
|
|
|
|
# When Docker creates named volumes they are owned by root, but the
|
|
|
|
|
# application runs as the unprivileged "oxicloud" user (UID 1001).
|
|
|
|
|
# This script runs as root, fixes permissions, then drops privileges.
|
|
|
|
|
|
|
|
|
|
STORAGE_DIR="/app/storage"
|
|
|
|
|
STATIC_DIR="/app/static"
|
|
|
|
|
|
|
|
|
|
# Ensure the storage directory exists and is writable by oxicloud
|
2026-05-29 16:51:05 +02:00
|
|
|
if [ -d "$STORAGE_DIR" ] && [ "$(id -u)" -eq 0 ]; then
|
2026-02-12 09:57:33 +01:00
|
|
|
chown -R oxicloud:oxicloud "$STORAGE_DIR"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Ensure static directory is readable
|
2026-05-29 16:51:05 +02:00
|
|
|
if [ -d "$STATIC_DIR" ] && [ "$(id -u)" -eq 0 ]; then
|
2026-02-12 09:57:33 +01:00
|
|
|
chown -R oxicloud:oxicloud "$STATIC_DIR"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Drop privileges and exec the main binary (or whatever was passed as CMD)
|
2026-05-29 16:51:05 +02:00
|
|
|
if [ "$(id -u)" -eq 0 ]; then
|
2026-05-25 17:12:08 +02:00
|
|
|
exec su-exec oxicloud "$@"
|
|
|
|
|
else
|
|
|
|
|
oxicloud "$@"
|
|
|
|
|
fi
|