entrypoint.sh 500 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env sh
  2. file_env() {
  3. var="$1"
  4. fileVar="${var}_FILE"
  5. val_var="$(printenv "$var")"
  6. val_fileVar="$(printenv "$fileVar")"
  7. if [ -n "$val_var" ] && [ -n "$val_fileVar" ]; then
  8. echo "error: both $var and $fileVar are set (but are exclusive)" >&2
  9. exit 1
  10. fi
  11. if [ -n "$val_var" ]; then
  12. val="$val_var"
  13. elif [ -n "$val_fileVar" ]; then
  14. val="$(cat "$val_fileVar")"
  15. fi
  16. export "$var"="$val"
  17. unset "$fileVar"
  18. }
  19. file_env "MEMOS_DSN"
  20. exec "$@"