diff options
author | Pavel Raiskup <praiskup@redhat.com> | 2015-03-20 11:51:49 +0100 |
---|---|---|
committer | Pavel Raiskup <praiskup@redhat.com> | 2015-03-20 11:58:52 +0100 |
commit | d529834d22549b48c54546d1fa463b93a0859025 (patch) | |
tree | 10018c9342c66d18bfef424b7c3485cc25dbc050 /postgresql-setup.in | |
parent | d95bc9eaaf44776349c05a44d42f3b84e574d936 (diff) | |
download | postgresql-setup-d529834d22549b48c54546d1fa463b93a0859025.tar.gz postgresql-setup-d529834d22549b48c54546d1fa463b93a0859025.tar.xz postgresql-setup-d529834d22549b48c54546d1fa463b93a0859025.zip |
setup: enhance --new-systemd-unitv3.2
Do not left created dropin directory in case of some initdb
failure, or so. This allow user run the same --new-systemd-unit
repeatedly without changing the command-line.
* postgresql-setup.in (exit_handler): New exit callback wrapper.
($cleanup_dropin): Code to be executed to clean drop-in directory.
(generate_systemd_dropin): Fill $cleanup_dropin callback.
(initdb): Clean $cleanup_dropin in case of successful initdb.
This is not needed for upgrade() because we never create drop-ins
there.
* NEWS: Document changes.
Diffstat (limited to 'postgresql-setup.in')
-rw-r--r-- | postgresql-setup.in | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/postgresql-setup.in b/postgresql-setup.in index e4f640a..0337bdd 100644 --- a/postgresql-setup.in +++ b/postgresql-setup.in @@ -168,6 +168,7 @@ initdb() info $"Initializing database in '$pgdata'$port_info" if check_not_initialized && perform_initdb; then info $"Initialized, logs are in ${initdb_log}" + cleanup_dropin= else error $"Initializing database failed, possibly see $initdb_log" script_result=1 @@ -324,6 +325,8 @@ generate_systemd_dropin() mkdir -p "$dropindir" \ || die "Can not create '$dropindir'" + cleanup_dropin="rm -rf \"$dropindir\"" + cat <<EOF > "$dropin" || die "Can not write to '$dropin'" [Service] Environment=PGDATA=$pgdata @@ -502,6 +505,16 @@ service_configuration() test -n "$envfile_pgport" && set_var "$portvar" "$envfile_pgport" } +cleanup_dropin= +exit_handler() +{ + test -n "$cleanup_dropin" && { + info "cleaning up created dropin directory" + eval "$cleanup_dropin" + } +} + +trap exit_handler 0 # <Compat> # Alow users to use the old style arguments like |