diff options
author | Tom Lane <tgl@redhat.com> | 2012-03-17 12:47:37 -0400 |
---|---|---|
committer | Tom Lane <tgl@redhat.com> | 2012-03-17 12:47:37 -0400 |
commit | 26914bdffa7aa3eff4da9e93a59aa212ceab02e1 (patch) | |
tree | fd597249a1535dcf9ac3640b207e888e79b963c3 | |
parent | 628f33b2f41f07dcb9048891875e7f0bfa9ae39b (diff) | |
download | postgresql-setup-26914bdffa7aa3eff4da9e93a59aa212ceab02e1.tar.gz postgresql-setup-26914bdffa7aa3eff4da9e93a59aa212ceab02e1.tar.xz postgresql-setup-26914bdffa7aa3eff4da9e93a59aa212ceab02e1.zip |
Fix postgresql-setup to rely on systemd to parse the unit file
-rw-r--r-- | postgresql-setup | 33 | ||||
-rw-r--r-- | postgresql.service | 9 |
2 files changed, 24 insertions, 18 deletions
diff --git a/postgresql-setup b/postgresql-setup index 29da10a..132ef78 100644 --- a/postgresql-setup +++ b/postgresql-setup @@ -23,24 +23,27 @@ then SERVICE_NAME=postgresql fi -if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ] -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" ] +# 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="/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 ] diff --git a/postgresql.service b/postgresql.service index 4414d11..123c4fe 100644 --- a/postgresql.service +++ b/postgresql.service @@ -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 |