Fix postgresql-setup to rely on systemd to parse the unit file
This commit is contained in:
parent
338b75480d
commit
de5b387d8f
@ -23,24 +23,27 @@ then
|
||||
SERVICE_NAME=postgresql
|
||||
fi
|
||||
|
||||
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]
|
||||
# this parsing technique fails for PGDATA pathnames containing spaces,
|
||||
# but there's not much I can do about it given systemctl's output format...
|
||||
PGDATA=`systemctl show -p Environment "${SERVICE_NAME}.service" |
|
||||
sed 's/^Environment=//' | tr ' ' '\n' |
|
||||
sed -n 's/^PGDATA=//p' | tail -n 1`
|
||||
|
||||
if [ x"$PGDATA" = x ]
|
||||
then
|
||||
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
|
||||
elif [ -f "/usr/lib/systemd/system/${SERVICE_NAME}.service" ]
|
||||
then
|
||||
SERVICE_FILE="/usr/lib/systemd/system/${SERVICE_NAME}.service"
|
||||
# this case should go away eventually, but not till F16 is dead:
|
||||
elif [ -f "/lib/systemd/system/${SERVICE_NAME}.service" ]
|
||||
then
|
||||
SERVICE_FILE="/lib/systemd/system/${SERVICE_NAME}.service"
|
||||
else
|
||||
echo "Could not find systemd unit file ${SERVICE_NAME}.service"
|
||||
echo "failed to find PGDATA setting in ${SERVICE_NAME}.service"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get port number and data directory from the service file
|
||||
PGPORT=`sed -n 's/^[ \t]*Environment=PGPORT=//p' "${SERVICE_FILE}"`
|
||||
PGDATA=`sed -n 's/^[ \t]*Environment=PGDATA=//p' "${SERVICE_FILE}"`
|
||||
PGPORT=`systemctl show -p Environment "${SERVICE_NAME}.service" |
|
||||
sed 's/^Environment=//' | tr ' ' '\n' |
|
||||
sed -n 's/^PGPORT=//p' | tail -n 1`
|
||||
|
||||
if [ x"$PGPORT" = x ]
|
||||
then
|
||||
echo "failed to find PGPORT setting in ${SERVICE_NAME}.service"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Log file for initdb
|
||||
PGLOG=/var/lib/pgsql/initdb.log
|
||||
@ -48,8 +51,8 @@ PGLOG=/var/lib/pgsql/initdb.log
|
||||
# Log file for pg_upgrade
|
||||
PGUPLOG=/var/lib/pgsql/pgupgrade.log
|
||||
|
||||
export PGPORT
|
||||
export PGDATA
|
||||
export PGPORT
|
||||
|
||||
# For SELinux we need to use 'runuser' not 'su'
|
||||
if [ -x /sbin/runuser ]
|
||||
|
@ -14,6 +14,12 @@
|
||||
# Environment=PGPORT=5433
|
||||
# This will override the setting appearing below.
|
||||
|
||||
# Note: do not use a PGDATA pathname containing spaces, or you will
|
||||
# break postgresql-setup.
|
||||
|
||||
# Note: in F-17 and beyond, /usr/lib/... is recommended in the .include line
|
||||
# though /lib/... will still work.
|
||||
|
||||
[Unit]
|
||||
Description=PostgreSQL database server
|
||||
After=syslog.target
|
||||
@ -25,9 +31,6 @@ Type=forking
|
||||
User=postgres
|
||||
Group=postgres
|
||||
|
||||
# Note: avoid inserting whitespace in these Environment= lines, or you may
|
||||
# break postgresql-setup.
|
||||
|
||||
# Port number for server to listen on
|
||||
Environment=PGPORT=5432
|
||||
|
||||
|
@ -53,7 +53,7 @@ Summary: PostgreSQL client programs
|
||||
Name: postgresql
|
||||
%global majorversion 9.1
|
||||
Version: 9.1.3
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
|
||||
# The PostgreSQL license is very similar to other MIT licenses, but the OSI
|
||||
# recognizes it as an independent license, so we do as well.
|
||||
@ -932,6 +932,11 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Sat Mar 17 2012 Tom Lane <tgl@redhat.com> 9.1.3-3
|
||||
- Fix postgresql-setup to rely on systemd to parse the unit file, instead
|
||||
of using ad-hoc code
|
||||
Resolves: #804290
|
||||
|
||||
* Tue Mar 13 2012 Tom Lane <tgl@redhat.com> 9.1.3-2
|
||||
- Fix postgresql-setup to look for unit file in /usr/lib and to ignore
|
||||
comments therein
|
||||
|
Loading…
Reference in New Issue
Block a user