01-permissions.sh 1.0 KB

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. source /docker/helpers.sh
  3. entrypoint-set-script-name "$0"
  4. # Ensure the two Docker volumes and dot-env files are owned by the runtime user as other scripts
  5. # will be writing to these
  6. run-as-current-user chown --verbose ${RUNTIME_UID}:${RUNTIME_GID} "./.env"
  7. run-as-current-user chown --verbose ${RUNTIME_UID}:${RUNTIME_GID} "./bootstrap/cache"
  8. run-as-current-user chown --verbose ${RUNTIME_UID}:${RUNTIME_GID} "./storage"
  9. # Optionally fix ownership of configured paths
  10. : ${ENTRYPOINT_ENSURE_OWNERSHIP_PATHS:=""}
  11. declare -a ensure_ownership_paths=()
  12. IFS=' ' read -a ensure_ownership_paths <<<"${ENTRYPOINT_ENSURE_OWNERSHIP_PATHS}"
  13. if [[ ${#ensure_ownership_paths[@]} == 0 ]]; then
  14. log-info "No paths has been configured for ownership fixes via [\$ENTRYPOINT_ENSURE_OWNERSHIP_PATHS]."
  15. exit 0
  16. fi
  17. for path in "${ensure_ownership_paths[@]}"; do
  18. log-info "Ensure ownership of [${path}] is correct"
  19. stream-prefix-command-output run-as-current-user chown --recursive ${RUNTIME_UID}:${RUNTIME_GID} "${path}"
  20. done