diff options
author | Pavel Raiskup <praiskup@redhat.com> | 2014-07-03 14:01:52 +0200 |
---|---|---|
committer | Pavel Raiskup <praiskup@redhat.com> | 2014-07-03 14:04:03 +0200 |
commit | ae8bfd7109395216ebb802499084fe890038a78f (patch) | |
tree | 1d4c4110f6600d17c174f26ad15be573b4be945d | |
parent | d83a864291c9f113d27bfb90d21fede7c35cdcf3 (diff) | |
download | postgresql-setup-ae8bfd7109395216ebb802499084fe890038a78f.tar.gz postgresql-setup-ae8bfd7109395216ebb802499084fe890038a78f.tar.xz postgresql-setup-ae8bfd7109395216ebb802499084fe890038a78f.zip |
upgrade/initdb logs: diverge among service names
Generate separate log file for each service. Also, don't
configure with INITDB_LOG or UPGRADE_LOG but rather with
POSTGRES_HOME.
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | postgresql-setup.in | 40 |
3 files changed, 26 insertions, 30 deletions
diff --git a/Makefile.am b/Makefile.am index 64868f7..e4d6907 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,6 @@ nodist_pgdoc_DATA = README.rpm-dist # need fully expanded strings there. edit = $(SED) \ -e 's|@DISTSUFF[@]|$(DISTSUFF)|g' \ - -e 's|@INITDB_LOG[@]|$(INITDB_LOG)|g' \ -e 's|@libexecdir[@]|$(libexecdir)|g' \ -e 's|@PG_CTL_BIN[@]|$(PG_CTL_BIN)|g' \ -e 's|@PGDATADIR[@]|$(PGDATADIR)|g' \ @@ -27,11 +26,11 @@ edit = $(SED) \ -e 's|@PGMAJORVERSION[@]|$(PGMAJORVERSION)|g' \ -e 's|@PGVERSION[@]|$(PGVERSION)|g' \ -e 's|@PKGCONFIG_DIR[@]|$(PKGCONFIG_DIR)|g' \ + -e 's|@POSTGRES_HOMEDIR[@]|$(POSTGRES_HOMEDIR)|g' \ -e 's|@PREVMAJORVERSION[@]|$(PREVMAJORVERSION)|g' \ -e 's|@PREVPGENGINE[@]|$(PREVPGENGINE)|g' \ -e 's|@README_DIST[@]|$(README_DIST)|g' \ -e 's|@SU[@]|$(SU)|g' \ - -e 's|@UPGRADE_LOG[@]|$(UPGRADE_LOG)|g' \ -e 's|@VERSION[@]|$(VERSION)|g' \ $< > $@ diff --git a/configure.ac b/configure.ac index f496066..df10f3d 100644 --- a/configure.ac +++ b/configure.ac @@ -143,16 +143,14 @@ redhat) ;; esac -test -z "$INITDB_LOG" && - INITDB_LOG=/var/lib/pgsql/initdb.log - -test -z "$UPGRADE_LOG" && - UPGRADE_LOG=/var/lib/pgsql/pgupgrade.log - if test -z "$PKGCONFIG_DIR" -a "$distro_family" = redhat; then PKGCONFIG_DIR=/etc/postgresql fi +if test -z "$POSTGRES_HOMEDIR" -a "$distro_family" = redhat; then + POSTGRES_HOMEDIR=/var/lib/pgsql +fi + if test -z "$PGDATADIR" -a "$distro_family" = redhat; then PGDATADIR=/var/lib/pgsql/data fi @@ -168,9 +166,8 @@ subst_required_var([PGENGINE], [directory where PG server resides]) subst_required_var([PREVMAJORVERSION], [PG major version to upgrade _from_]) subst_required_var([PREVPGENGINE], [directory where old PG server resides]) subst_required_var([README_DIST], [README file for distribution]) -subst_required_var([INITDB_LOG], [log file for initdb]) -subst_required_var([UPGRADE_LOG], [log file for pg_upgrade]) subst_required_var([PKGCONFIG_DIR], [where configuration should be stored]) +subst_required_var([POSTGRES_HOMEDIR], [full path to postgres home dir]) subst_required_var([PGDATADIR], [full path to postgres data dir]) AC_OUTPUT diff --git a/postgresql-setup.in b/postgresql-setup.in index fa92998..7f7c6c9 100644 --- a/postgresql-setup.in +++ b/postgresql-setup.in @@ -24,11 +24,8 @@ PREVPGENGINE=@PREVPGENGINE@ # Distribution README file README_DIST=@README_DIST@ -# Log file for initdb -PGLOG=@INITDB_LOG@ - -# Log file for pg_upgrade -PGUPLOG=@UPGRADE_LOG@ +# Home directory of postgres user +POSTGRES_HOMEDIR=@POSTGRES_HOMEDIR@ SYSCONFIG_DIR=@PKGCONFIG_DIR@ @@ -103,18 +100,18 @@ perform_initdb() [ -x /sbin/restorecon ] && /sbin/restorecon "$pgdata" # Create the initdb log file if needed - if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]; then - touch "$PGLOG" || return 1 - chown postgres:postgres "$PGLOG" - chmod go-rwx "$PGLOG" - [ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG" + if [ ! -e "$initdb_log" -a ! -h "$initdb_log" ]; then + touch "$initdb_log" || return 1 + chown postgres:postgres "$initdb_log" + chmod go-rwx "$initdb_log" + [ -x /sbin/restorecon ] && /sbin/restorecon "$initdb_log" fi # Initialize the database initdbcmd="$PGENGINE/initdb --pgdata='$pgdata' --auth='ident'" initdbcmd+=" $PGSETUP_INITDB_OPTIONS" - $SU -l postgres -c "$initdbcmd" >> "$PGLOG" 2>&1 < /dev/null + $SU -l postgres -c "$initdbcmd" >> "$initdb_log" 2>&1 < /dev/null # Create directory for postmaster log files mkdir "$pgdata/pg_log" @@ -152,9 +149,9 @@ initdb() else info $"Initializing database in $pgdata." if perform_initdb; then - info $"Initialized." + info $"Initialized, logs are in ${initdb_log}." else - error $"Initializing database failed, see $PGLOG" + error $"Initializing database failed, see $initdb_log" script_result=1 fi fi @@ -179,11 +176,11 @@ upgrade() fi # Set up log file for pg_upgrade - rm -f "$PGUPLOG" - touch "$PGUPLOG" || exit 1 - chown postgres:postgres "$PGUPLOG" - chmod go-rwx "$PGUPLOG" - [ -x /sbin/restorecon ] && /sbin/restorecon "$PGUPLOG" + rm -f "$upgrade_log" + touch "$upgrade_log" || exit 1 + chown postgres:postgres "$upgrade_log" + chmod go-rwx "$upgrade_log" + [ -x /sbin/restorecon ] && /sbin/restorecon "$upgrade_log" # Move old DB to pgdataold pgdataold="${pgdata}-old" @@ -218,7 +215,7 @@ upgrade() '--old-port=$PGPORT' '--new-port=$PGPORT' \ --user=postgres \ $PGSETUP_PGUPGRADE_OPTIONS" \ - >> "$PGUPLOG" 2>&1 < /dev/null + >> "$upgrade_log" 2>&1 < /dev/null if [ $? -ne 0 ]; then # pg_upgrade failed script_result=1 @@ -246,7 +243,7 @@ upgrade() echo $"failed" fi echo - echo $"See $PGUPLOG for details." + echo $"See $upgrade_log for details." } @@ -458,6 +455,9 @@ test "$option_mode" = none \ [[ "$option_port" =~ ^[0-9]*$ ]] \ || die $"port set to '$option_port', must be integer number" +initdb_log="$POSTGRES_HOMEDIR/initdb_${option_service}.log" +upgrade_log="$POSTGRES_HOMEDIR/upgrade_${option_service}.log" + test -n "$option_port" && pgport=$option_port debug "mode used: $option_mode" |