Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a custom post-installation script to be run once #71

Closed
fluca1978 opened this issue Apr 11, 2024 · 3 comments · Fixed by #72
Closed

Add support for a custom post-installation script to be run once #71

fluca1978 opened this issue Apr 11, 2024 · 3 comments · Fixed by #72
Assignees

Comments

@fluca1978
Copy link
Collaborator

The idea is to provide a way to let users to run a custom script at the very first start of the PostgreSQL cluster, so to allow them to automatically initialize their cluster(s).
The script has to be run only once per cluster, at the very first start of the instance. In that sense, is a special kind of post-start script.
See discussion in #70.

@fluca1978 fluca1978 self-assigned this Apr 11, 2024
fluca1978 added a commit to fluca1978/pgenv that referenced this issue Apr 11, 2024
This commit introduces a new configuration parameter
`PGENV_SCRIPT_FIRSTSTART` that can be pointed to an executable that is
run once and only once at the very first start of the selected
instance.
Therefore, the usage of this script enables for customization of the
instance, like for example adding new users and databases.

The changes are made directly into the `pgenv_start_instance`
function, that is the entry point to a start action: the function in
turns calls `pgenv_initdb` that performs the initialization of the
instace. If the initialization is done, a new magic variable
`PGENV_INITDB_DONE` is set to `1`, so that `pgenv_start_instance` can
then decide to execute the script mentioned above.

Therefore, the trick here is to mark a "first start" time as the one
that immediatly follows the initdb phase.

Close theory#71
@fluca1978
Copy link
Collaborator Author

@theory can you please take a look at my implementation? If this is ok we can merge and issue a new release.

@theory
Copy link
Owner

theory commented Apr 11, 2024

Looks good. Can you open a PR? Will pull it and try it out.

@fluca1978
Copy link
Collaborator Author

Looks good. Can you open a PR? Will pull it and try it out.

ops, sorry, I didn't have my coffee!

fluca1978 added a commit to fluca1978/pgenv that referenced this issue Apr 15, 2024
This commit introduces a new configuration parameter
`PGENV_SCRIPT_FIRSTSTART` that can be pointed to an executable that is
run once and only once at the very first start of the selected
instance.
Therefore, the usage of this script enables for customization of the
instance, like for example adding new users and databases.

The changes are made directly into the `pgenv_start_instance`
function, that is the entry point to a start action: the function in
turns calls `pgenv_initdb` that performs the initialization of the
instace. If the initialization is done, a new magic variable
`PGENV_INITDB_DONE` is set to `1`, so that `pgenv_start_instance` can
then decide to execute the script mentioned above.

Therefore, the trick here is to mark a "first start" time as the one
that immediatly follows the initdb phase.

Documentation updated.
Version number bumped.

Close theory#71
fluca1978 added a commit that referenced this issue Apr 15, 2024
This commit introduces a new configuration parameter
`PGENV_SCRIPT_FIRSTSTART` that can be pointed to an executable that is
run once and only once at the very first start of the selected
instance.
Therefore, the usage of this script enables for customization of the
instance, like for example adding new users and databases.

The changes are made directly into the `pgenv_start_instance`
function, that is the entry point to a start action: the function in
turns calls `pgenv_initdb` that performs the initialization of the
instace. If the initialization is done, a new magic variable
`PGENV_INITDB_DONE` is set to `1`, so that `pgenv_start_instance` can
then decide to execute the script mentioned above.

Therefore, the trick here is to mark a "first start" time as the one
that immediatly follows the initdb phase.

Documentation updated.
Version number bumped.

Close #71
fluca1978 added a commit that referenced this issue Apr 15, 2024
This commit introduces a new configuration parameter
`PGENV_SCRIPT_FIRSTSTART` that can be pointed to an executable that is
run once and only once at the very first start of the selected
instance.
Therefore, the usage of this script enables for customization of the
instance, like for example adding new users and databases.

The changes are made directly into the `pgenv_start_instance`
function, that is the entry point to a start action: the function in
turns calls `pgenv_initdb` that performs the initialization of the
instace. If the initialization is done, a new magic variable
`PGENV_INITDB_DONE` is set to `1`, so that `pgenv_start_instance` can
then decide to execute the script mentioned above.

Therefore, the trick here is to mark a "first start" time as the one
that immediatly follows the initdb phase.

Documentation updated.
Version number bumped.

Close #71
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants