Fix postgresql-setup, re-add init script

This commit is contained in:
Tom Lane 2012-03-13 19:38:14 -04:00
parent 2e73ff757c
commit 338b75480d
3 changed files with 64 additions and 3 deletions

View File

@ -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

44
postgresql.init Normal file
View File

@ -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 $?

View File

@ -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@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@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