[postgresql/f16] Fix postgresql-setup, re-add init script

Tom Lane tgl at fedoraproject.org
Tue Mar 13 23:45:28 UTC 2012


commit b1edb8c67f4124067105c7e56152d2f4771044fd
Author: Tom Lane <tgl at redhat.com>
Date:   Tue Mar 13 19:38:14 2012 -0400

    Fix postgresql-setup, re-add init script

 postgresql-setup |    8 ++++++--
 postgresql.init  |   44 ++++++++++++++++++++++++++++++++++++++++++++
 postgresql.spec  |   15 ++++++++++++++-
 3 files changed, 64 insertions(+), 3 deletions(-)
---
diff --git a/postgresql-setup b/postgresql-setup
index 8b2a9ce..29da10a 100644
--- a/postgresql-setup
+++ b/postgresql-setup
@@ -26,6 +26,10 @@ 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" ]
 then
     SERVICE_FILE="/lib/systemd/system/${SERVICE_NAME}.service"
@@ -35,8 +39,8 @@ else
 fi
 
 # Get port number and data directory from the service file
-PGPORT=`sed -n 's/Environment=PGPORT=//p' "${SERVICE_FILE}"`
-PGDATA=`sed -n 's/Environment=PGDATA=//p' "${SERVICE_FILE}"`
+PGPORT=`sed -n 's/^[ \t]*Environment=PGPORT=//p' "${SERVICE_FILE}"`
+PGDATA=`sed -n 's/^[ \t]*Environment=PGDATA=//p' "${SERVICE_FILE}"`
 
 # Log file for initdb
 PGLOG=/var/lib/pgsql/initdb.log
diff --git a/postgresql.init b/postgresql.init
new file mode 100644
index 0000000..46e1294
--- /dev/null
+++ b/postgresql.init
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# This is not needed any more for the standard systemctl-supported actions,
+# but we keep it around for the nonstandard actions (initdb, upgrade).
+# People are too used to getting at those via "service postgresql foo ..."
+
+# Find the name of the script
+NAME=`basename $0`
+if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ]
+then
+	NAME=${NAME:3}
+fi
+
+case "$1" in
+  start)
+	systemctl start ${NAME}.service
+	;;
+  stop)
+	systemctl stop ${NAME}.service
+	;;
+  status)
+	systemctl status ${NAME}.service
+	;;
+  restart)
+	systemctl restart ${NAME}.service
+	;;
+  condrestart|try-restart)
+	systemctl try-restart ${NAME}.service
+	;;
+  reload)
+	systemctl reload ${NAME}.service
+	;;
+  initdb)
+	postgresql-setup initdb
+	;;
+  upgrade)
+	postgresql-setup upgrade
+	;;
+  *)
+	echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|initdb|upgrade}"
+	exit 2
+esac
+
+exit $?
diff --git a/postgresql.spec b/postgresql.spec
index 3fd9bea..3bc92c4 100644
--- a/postgresql.spec
+++ b/postgresql.spec
@@ -53,7 +53,7 @@ Summary: PostgreSQL client programs
 Name: postgresql
 %global majorversion 9.1
 Version: 9.1.3
-Release: 1%{?dist}
+Release: 2%{?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.
@@ -83,6 +83,7 @@ Source7: ecpg_config.h
 Source8: README.rpm-dist
 Source9: postgresql-setup
 Source10: postgresql.service
+Source11: postgresql.init
 Source14: postgresql.pam
 Source15: postgresql-bashprofile
 
@@ -473,6 +474,9 @@ install -m 755 postgresql-check-db-dir $RPM_BUILD_ROOT%{_bindir}/postgresql-chec
 install -d $RPM_BUILD_ROOT%{_unitdir}
 install -m 644 %{SOURCE10} $RPM_BUILD_ROOT%{_unitdir}/postgresql.service
 
+install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
+install -m 755 %{SOURCE11} $RPM_BUILD_ROOT/etc/rc.d/init.d/postgresql
+
 %if %pam
 install -d $RPM_BUILD_ROOT/etc/pam.d
 install -m 644 %{SOURCE14} $RPM_BUILD_ROOT/etc/pam.d/postgresql
@@ -830,6 +834,7 @@ rm -rf $RPM_BUILD_ROOT
 %files server -f server.lst
 %defattr(-,root,root)
 %{_unitdir}/postgresql.service
+/etc/rc.d/init.d/postgresql
 %if %pam
 %config(noreplace) /etc/pam.d/postgresql
 %endif
@@ -927,6 +932,14 @@ rm -rf $RPM_BUILD_ROOT
 %endif
 
 %changelog
+* Tue Mar 13 2012 Tom Lane <tgl at redhat.com> 9.1.3-2
+- Fix postgresql-setup to look for unit file in /usr/lib and to ignore
+  comments therein
+Resolves: #802835
+- Resurrect a now-mostly-dummy postgresql init script, so that people can
+  keep on using "service postgresql initdb" if they wish
+Resolves: #800416
+
 * Mon Feb 27 2012 Tom Lane <tgl at redhat.com> 9.1.3-1
 - Update to PostgreSQL 9.1.3, for various fixes described at
   http://www.postgresql.org/docs/9.1/static/release-9-1-3.html


More information about the scm-commits mailing list