-
Notifications
You must be signed in to change notification settings - Fork 29
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
[#71] Add support for "run once" custom script #72
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a couple corrections, otherwise works great for me! I will use this, in fact. Here's my script:
#!/bin/sh
createuser -sU postgres
createdb
bin/pgenv
Outdated
cat <<EOF | ||
This is the first time PostgreSQL $v is started, | ||
executing the \`PGENV_SCRIPT_FIRSTSTART\` script | ||
$PGENV_SCRIPT_FIRSTSTART" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No opening quotation mark here. Should it be this?
$PGENV_SCRIPT_FIRSTSTART" | |
"$PGENV_SCRIPT_FIRSTSTART" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIXED
bin/pgenv
Outdated
@@ -781,7 +781,8 @@ pgenv_configuration_write() { | |||
pgenv_configuration_write_variable "$CONF" "PGENV_RESTART_OPTIONS" "" 'Restart configuration flags' | |||
|
|||
pgenv_configuration_write_variable "$CONF" "PGENV_SCRIPT_POSTINSTALL" "" 'Script to execute when the build process finishes' | |||
pgenv_configuration_write_variable "$CONF" "PGENV_SCRIPT_POSTINITDB" "" 'Script to execute when initdb finishes' | |||
pgenv_configuration_write_variable "$CONF" "PGENV_SCRIPT_POSTINITDB" "" 'Script to execute when initdb finishes (and the server has not started yet)' | |||
pgenv_configuration_write_variable "$CONF" "PGENV_SCRIPT_FIRSTART" "" 'Script to execute at the very first start of the instance' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pgenv_configuration_write_variable "$CONF" "PGENV_SCRIPT_FIRSTART" "" 'Script to execute at the very first start of the instance' | |
pgenv_configuration_write_variable "$CONF" "PGENV_SCRIPT_FIRSTSTART" "" 'Script to execute at the very first start of the instance' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shame on me, I was testing without having noted the configuration file produced did have the misspelled word!
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
007cf84
to
8d2c963
Compare
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 callspgenv_initdb
that performs the initialization of the instace. If the initialization is done, a new magic variablePGENV_INITDB_DONE
is set to1
, so thatpgenv_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 #71