Skip to content

Allow "initdb.d" scripts to be (optionally) sourced instead of executed #490

Closed
@dakotahawkins

Description

@dakotahawkins

Kind-of the opposite of #452 (which fixes #450), but I'd be fine with the current behavior by default provided there can be some means (file name or extension) of sourcing instead of executing.

Rationale:

I have an initialization script that needs file_env(), $POSTGRES_DB, and ${psql[@]}.

When the script is sourced it works, but as none of those are exported, it doesn't work if it's executed. We've had to take care to chmod -x the file to work around this after #452, but that seems kind-of hacky and hard to maintain.

Possible options:

  1. Informal naming convention, e.g. source_*.sh, *.source.sh, .*, or similar
    • Might be hard to document, know about
    • Could be triggered accidentally by unaware users
  2. Separate directory or subdirectory
  3. Export (optionally?) useful functions/variables
    • Hard to maintain
    • Maybe undesirable by default for some users?
  4. Have the default case try to source $f instead of ignoring it
    • Maybe users are exploiting current behavior and putting weird files here for some reason

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    RequestRequest for image modification or feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions