1
0
Fork 0
pixelfed/docker/shared/root/docker/entrypoint.d/01-permissions.sh

31 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/bash
2024-01-15 17:16:00 +00:00
: "${ENTRYPOINT_ROOT:="/docker"}"
# shellcheck source=SCRIPTDIR/../helpers.sh
source "${ENTRYPOINT_ROOT}/helpers.sh"
2024-01-05 00:11:20 +00:00
entrypoint-set-script-name "$0"
2024-01-05 23:16:26 +00:00
# Ensure the two Docker volumes and dot-env files are owned by the runtime user as other scripts
# will be writing to these
2024-01-15 17:16:00 +00:00
run-as-current-user chown --verbose "${RUNTIME_UID}:${RUNTIME_GID}" "./.env"
run-as-current-user chown --verbose "${RUNTIME_UID}:${RUNTIME_GID}" "./bootstrap/cache"
run-as-current-user chown --verbose "${RUNTIME_UID}:${RUNTIME_GID}" "./storage"
2024-01-05 17:29:45 +00:00
# Optionally fix ownership of configured paths
: "${DOCKER_APP_ENSURE_OWNERSHIP_PATHS:=""}"
declare -a ensure_ownership_paths=()
IFS=' ' read -ar ensure_ownership_paths <<<"${DOCKER_APP_ENSURE_OWNERSHIP_PATHS}"
2024-01-04 23:04:25 +00:00
if [[ ${#ensure_ownership_paths[@]} == 0 ]]; then
log-info "No paths has been configured for ownership fixes via [\$DOCKER_APP_ENSURE_OWNERSHIP_PATHS]."
exit 0
fi
for path in "${ensure_ownership_paths[@]}"; do
2024-01-04 23:04:25 +00:00
log-info "Ensure ownership of [${path}] is correct"
2024-01-15 17:16:00 +00:00
stream-prefix-command-output run-as-current-user chown --recursive "${RUNTIME_UID}:${RUNTIME_GID}" "${path}"
done