summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2015-03-18 17:37:06 +0100
committerPavel Raiskup <praiskup@redhat.com>2015-03-18 17:40:56 +0100
commitf4cc12884c91a3edd17fa6a19b8ea4d50226597c (patch)
tree93f49830fc3a835f3ea9b8bb597b48b3ad4a8866
parent0692b79c7ec32c010723b889cac0d3b8bcb8f4ce (diff)
downloadpostgresql-setup-f4cc12884c91a3edd17fa6a19b8ea4d50226597c.zip
postgresql-setup-f4cc12884c91a3edd17fa6a19b8ea4d50226597c.tar.gz
postgresql-setup-f4cc12884c91a3edd17fa6a19b8ea4d50226597c.tar.xz
sysvinit: initscript & postgresql-setup fixes
* postgresql-setup.in($USAGE_STRING): Don't output sysvinit not-relevant options. Generalize the help a bit to match sysvinit. Throw a better warning if user runs 'service initdb postgresql@blah', and, the --port was not passed. In this case, postgresql.conf can't be used. * postgresql.init.in (initdb, upgrade): Add --unit option to postgresql-setup call.
-rw-r--r--postgresql-setup.in36
-rw-r--r--postgresql.init.in4
2 files changed, 25 insertions, 15 deletions
diff --git a/postgresql-setup.in b/postgresql-setup.in
index d4c73cf..a8a1edc 100644
--- a/postgresql-setup.in
+++ b/postgresql-setup.in
@@ -39,26 +39,33 @@ For more info and howto/when use this script please look at the documentation
file $README_DIST.
Available operation mode:
- --initdb Create a new PostgreSQL database cluster. This is usually the
+ --initdb Initialize new PostgreSQL database cluster. This is usually the
first action you perform after PostgreSQL server installation.
--upgrade Upgrade database cluster for new major version of PostgreSQL
server. See the --upgrade-from option for more info.
Options:
- --unit=UNIT_NAME The UNIT_NAME is used to select proper systemd's
- unit configuration. For example, if you want to
- work with unit 'postgresql@com_example.service',
- you should use 'postgresql@com_example' (without
- trailing .service string). When no UNIT_NAME is
- explicitly passed, the 'postgresql' string is used
- by default.
- --port=PORT port where the server will listen for connections
+ --unit=UNIT_NAME The UNIT_NAME is used to select proper unit
+ configuration (unit == service or initscript name
+ on non-systemd systems). For example, if you want
+ to work with unit called
+ 'postgresql@com_example.service', you should use
+ 'postgresql@com_example' (without trailing .service
+ string). When no UNIT_NAME is explicitly passed,
+ the 'postgresql' string is used by default.
+ --port=PORT port where the initialized server will listen for
+ connections"
+
+test 0 -eq @WANT_SYSVINIT@ && \
+USAGE_STRING+="
--datadir=PATH Specify absolute path to DB data directory, only
use with --new-systemd-unit.
--new-systemd-unit Pre-generate system'd configuration in drop-in
directory if the unit is not yet configured,
requires non-default --unit specified and explicit
- --datadir and --port.
+ --datadir and --port."
+
+USAGE_STRING+="
--upgrade-ids Print list of available IDs of upgrade scenarios to
standard output.
--upgrade-from=ID Specify id \"old\" postgresql stack to upgrade
@@ -686,9 +693,12 @@ if test "$pgport" = default -a "$option_service" = "@NAME_SERVICE@"; then
pgport=$PGPORT_DEF
fi
-test "$pgport" = default \
- && die $"\
-Port is not set by postgresql.conf nor by --port."
+if test "$pgport" = default; then
+ # initdb case.. Note that this may be called by initscripts. If this gets
+ # called by legacy script, we can't help too much because systemd does not
+ # allow passing additional arguments to 'service XX initdb' command.
+ die $"For non-default unit names you must specify port by --port option."
+fi
[[ "$option_port" =~ ^[0-9]*$ ]] \
|| die $"port set to '$option_port', must be integer number"
diff --git a/postgresql.init.in b/postgresql.init.in
index dc4c9a7..bf2e9ca 100644
--- a/postgresql.init.in
+++ b/postgresql.init.in
@@ -187,14 +187,14 @@ __single_comand()
initdb()
{
__single_comand $"Initializing database" \
- @bindir@/@NAME_BINARYBASE@-setup --initdb "$NAME" "$@"
+ @bindir@/@NAME_BINARYBASE@-setup --initdb --unit "$NAME" "$@"
}
upgrade()
{
__single_comand $"Upgrading database" \
- @bindir@/@NAME_BINARYBASE@-setup --upgrade "$NAME" "$@"
+ @bindir@/@NAME_BINARYBASE@-setup --upgrade --unit "$NAME" "$@"
}