Fix initscript LSB compliance issues
This commit is contained in:
parent
b7fa69b9cb
commit
9cc5f2029d
147
postgresql.init
147
postgresql.init
@ -1,79 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
#
|
||||||
# postgresql This is the init script for starting up the PostgreSQL
|
# postgresql This is the init script for starting up the PostgreSQL
|
||||||
# server
|
# server.
|
||||||
#
|
#
|
||||||
# chkconfig: - 64 36
|
# chkconfig: - 64 36
|
||||||
# description: Starts and stops the PostgreSQL backend daemon that handles \
|
# description: PostgreSQL database server.
|
||||||
# all database requests.
|
|
||||||
# processname: postmaster
|
# processname: postmaster
|
||||||
# pidfile: /var/run/postmaster.pid
|
# pidfile: /var/run/postmaster.PORT.pid
|
||||||
|
|
||||||
# Version 6.5.3-2 Lamar Owen
|
# This script is slightly unusual in that the name of the daemon (postmaster)
|
||||||
# Added code to determine if PGDATA exists, whether it is current version
|
# is not the same as the name of the subsystem (postgresql)
|
||||||
# or not, and initdb if no PGDATA (initdb will not overwrite a database).
|
|
||||||
|
|
||||||
# Version 7.0 Lamar Owen
|
|
||||||
# Added logging code
|
|
||||||
# Changed PGDATA.
|
|
||||||
|
|
||||||
# Version 7.0.2 Trond Eivind Glomsrd <teg@redhat.com>
|
|
||||||
# use functions, add conditional restart
|
|
||||||
|
|
||||||
# Version 7.0.3 Lamar Owen <lamar@postgresql.org>
|
|
||||||
# Check for the existence of functions before blindly using them
|
|
||||||
# in particular -- check for success () and failure () before using.
|
|
||||||
# More Cross-distribution support -- PGVERSION variable, and docdir checks.
|
|
||||||
|
|
||||||
# Version 7.1 Release Candidate Lamar Owen <lamar@postgresql.org>
|
|
||||||
# initdb parameters have changed.
|
|
||||||
|
|
||||||
# Version 7.1.2 Trond Eivind Glomsrd <teg@redhat.com>
|
|
||||||
# Specify shell for su
|
|
||||||
# Handle stop better - kill unwanted output, make it wait until the database is ready
|
|
||||||
# Handle locales slightly differently - always using "C" isn't a valid option
|
|
||||||
# Kill output from database initialization
|
|
||||||
# Mark messages for translation
|
|
||||||
|
|
||||||
# Version 7.1.2-2.PGDG Lamar Owen <lamar.owen@wgcr.org>
|
|
||||||
# sync up.
|
|
||||||
# Karl's fixes for some quoting issues.
|
|
||||||
|
|
||||||
# Version 7.2b2 Lamar Owen <lamar.owen@wgcr.org>
|
|
||||||
# version change.
|
|
||||||
|
|
||||||
# Version 7.2 final. Lamar Owen <lamar.owen@wgcr.org>
|
|
||||||
# reload from Peter E.
|
|
||||||
# Eliminate the pidof postmaster test in stop -- we're using pg_ctl so we don't need pidof.
|
|
||||||
# Tested the $? return for the stop script -- it does in fact propagate.
|
|
||||||
# TODO: multiple postmasters.
|
|
||||||
|
|
||||||
# Version 7.3 Lamar Owen <lamar.owen@ramifordistat.net>
|
|
||||||
# Multiple postmasters, courtesy Karl DeBisschop
|
|
||||||
|
|
||||||
# Version 7.4 Lamar Owen.
|
|
||||||
|
|
||||||
# Version 7.4.3 Tom Lane <tgl@sss.pgh.pa.us>
|
|
||||||
# Support condstop for uninstall
|
|
||||||
# Minor other changes suggested by Fernando Nasser.
|
|
||||||
|
|
||||||
# Version 7.4.5 Tom Lane <tgl@sss.pgh.pa.us>
|
|
||||||
# Rewrite to start postmaster directly, rather than via pg_ctl; this avoids
|
|
||||||
# fooling the postmaster's stale-lockfile check by having too many
|
|
||||||
# postgres-owned processes laying about.
|
|
||||||
|
|
||||||
# Version 8.1 Devrim Gunduz <devrim@PostgreSQL.org>
|
|
||||||
# Increased sleep time from 1 sec to 2 sec.
|
|
||||||
|
|
||||||
# Version 8.2 Devrim Gunduz <devrim@CommandPrompt.com>
|
|
||||||
# Set initdb as a seperate option.
|
|
||||||
|
|
||||||
# Version 8.3 Devrim Gunduz <devrim@CommandPrompt.com>
|
|
||||||
|
|
||||||
# Version 8.4 Devrim Gunduz <devrim@CommandPrompt.com>
|
|
||||||
# Remove "sameuser" from initdb, to match the new hba conf file.
|
|
||||||
|
|
||||||
# PGVERSION is the full package version, e.g., 8.4.0
|
# PGVERSION is the full package version, e.g., 8.4.0
|
||||||
# Note: the specfile ordinarily updates this during install
|
# Note: the specfile inserts the correct value during package build
|
||||||
PGVERSION=xxxx
|
PGVERSION=xxxx
|
||||||
# PGMAJORVERSION is major version, e.g., 8.4 (this should match PG_VERSION)
|
# PGMAJORVERSION is major version, e.g., 8.4 (this should match PG_VERSION)
|
||||||
PGMAJORVERSION=`echo "$PGVERSION" | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/'`
|
PGMAJORVERSION=`echo "$PGVERSION" | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/'`
|
||||||
@ -81,10 +20,7 @@ PGMAJORVERSION=`echo "$PGVERSION" | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/'`
|
|||||||
# Source function library.
|
# Source function library.
|
||||||
. /etc/rc.d/init.d/functions
|
. /etc/rc.d/init.d/functions
|
||||||
|
|
||||||
# Get function listing for cross-distribution logic.
|
# Get network config.
|
||||||
TYPESET=`typeset -f|grep "declare"`
|
|
||||||
|
|
||||||
# Get config.
|
|
||||||
. /etc/sysconfig/network
|
. /etc/sysconfig/network
|
||||||
|
|
||||||
# Find the name of the script
|
# Find the name of the script
|
||||||
@ -117,21 +53,20 @@ PG_OOM_ADJ=-17
|
|||||||
export PGDATA
|
export PGDATA
|
||||||
export PGPORT
|
export PGPORT
|
||||||
|
|
||||||
# Check that networking is up.
|
lockfile="/var/lock/subsys/${NAME}"
|
||||||
# Pretty much need it for postmaster.
|
pidfile="/var/run/postmaster.${PGPORT}.pid"
|
||||||
[ "${NETWORKING}" = "no" ] && exit 1
|
|
||||||
|
|
||||||
[ -f "$PGENGINE/postmaster" ] || exit 1
|
|
||||||
|
|
||||||
script_result=0
|
script_result=0
|
||||||
|
|
||||||
start(){
|
start(){
|
||||||
|
[ -x "$PGENGINE/postmaster" ] || exit 5
|
||||||
|
|
||||||
PSQL_START=$"Starting ${NAME} service: "
|
PSQL_START=$"Starting ${NAME} service: "
|
||||||
|
|
||||||
# Make sure startup-time log file is valid
|
# Make sure startup-time log file is valid
|
||||||
if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
|
if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
|
||||||
then
|
then
|
||||||
touch "$PGLOG" || exit 1
|
touch "$PGLOG" || exit 4
|
||||||
chown postgres:postgres "$PGLOG"
|
chown postgres:postgres "$PGLOG"
|
||||||
chmod go-rwx "$PGLOG"
|
chmod go-rwx "$PGLOG"
|
||||||
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
|
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
|
||||||
@ -140,8 +75,7 @@ start(){
|
|||||||
# Check for the PGDATA structure
|
# Check for the PGDATA structure
|
||||||
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
|
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
|
||||||
then
|
then
|
||||||
# Check version of existing PGDATA
|
# Check version of existing PGDATA
|
||||||
|
|
||||||
if [ x`cat "$PGDATA/PG_VERSION"` != x"$PGMAJORVERSION" ]
|
if [ x`cat "$PGDATA/PG_VERSION"` != x"$PGMAJORVERSION" ]
|
||||||
then
|
then
|
||||||
SYSDOCDIR="(Your System's documentation directory)"
|
SYSDOCDIR="(Your System's documentation directory)"
|
||||||
@ -167,10 +101,8 @@ start(){
|
|||||||
echo $"See $SYSDOCDIR/postgresql-$PGVERSION/README.rpm-dist for more information."
|
echo $"See $SYSDOCDIR/postgresql-$PGVERSION/README.rpm-dist for more information."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# No existing PGDATA! Warn the user to initdb it.
|
|
||||||
|
|
||||||
else
|
else
|
||||||
|
# No existing PGDATA! Warn the user to initdb it.
|
||||||
echo
|
echo
|
||||||
echo "$PGDATA is missing. Use \"service postgresql initdb\" to initialize the cluster first."
|
echo "$PGDATA is missing. Use \"service postgresql initdb\" to initialize the cluster first."
|
||||||
echo_failure
|
echo_failure
|
||||||
@ -182,12 +114,12 @@ start(){
|
|||||||
test x"$PG_OOM_ADJ" != x && echo "$PG_OOM_ADJ" > /proc/self/oom_adj
|
test x"$PG_OOM_ADJ" != x && echo "$PG_OOM_ADJ" > /proc/self/oom_adj
|
||||||
$SU -l postgres -c "$PGENGINE/postmaster -p '$PGPORT' -D '$PGDATA' ${PGOPTS} &" >> "$PGLOG" 2>&1 < /dev/null
|
$SU -l postgres -c "$PGENGINE/postmaster -p '$PGPORT' -D '$PGDATA' ${PGOPTS} &" >> "$PGLOG" 2>&1 < /dev/null
|
||||||
sleep 2
|
sleep 2
|
||||||
pid=`pidof -s "$PGENGINE/postmaster"`
|
pid=`head -n 1 "$PGDATA/postmaster.pid" 2>/dev/null`
|
||||||
if [ $pid ] && [ -f "$PGDATA/postmaster.pid" ]
|
if [ "x$pid" != x ]
|
||||||
then
|
then
|
||||||
success "$PSQL_START"
|
success "$PSQL_START"
|
||||||
touch /var/lock/subsys/${NAME}
|
touch "$lockfile"
|
||||||
head -n 1 "$PGDATA/postmaster.pid" > "/var/run/postmaster.${PGPORT}.pid"
|
echo $pid > "$pidfile"
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
failure "$PSQL_START"
|
failure "$PSQL_START"
|
||||||
@ -198,18 +130,24 @@ start(){
|
|||||||
|
|
||||||
stop(){
|
stop(){
|
||||||
echo -n $"Stopping ${NAME} service: "
|
echo -n $"Stopping ${NAME} service: "
|
||||||
$SU -l postgres -c "$PGENGINE/pg_ctl stop -D '$PGDATA' -s -m fast" > /dev/null 2>&1 < /dev/null
|
if [ -e "$lockfile" ]
|
||||||
ret=$?
|
|
||||||
if [ $ret -eq 0 ]
|
|
||||||
then
|
then
|
||||||
|
$SU -l postgres -c "$PGENGINE/pg_ctl stop -D '$PGDATA' -s -m fast" > /dev/null 2>&1 < /dev/null
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -eq 0 ]
|
||||||
|
then
|
||||||
echo_success
|
echo_success
|
||||||
else
|
rm -f "$pidfile"
|
||||||
|
rm -f "$lockfile"
|
||||||
|
else
|
||||||
echo_failure
|
echo_failure
|
||||||
script_result=1
|
script_result=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# not running; per LSB standards this is "ok"
|
||||||
|
echo_success
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
rm -f "/var/run/postmaster.${PGPORT}.pid"
|
|
||||||
rm -f "/var/lock/subsys/${NAME}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
restart(){
|
restart(){
|
||||||
@ -218,11 +156,7 @@ restart(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
condrestart(){
|
condrestart(){
|
||||||
[ -e /var/lock/subsys/${NAME} ] && restart
|
[ -e "$lockfile" ] && restart || :
|
||||||
}
|
|
||||||
|
|
||||||
condstop(){
|
|
||||||
[ -e /var/lock/subsys/${NAME} ] && stop
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reload(){
|
reload(){
|
||||||
@ -275,9 +209,6 @@ initdb(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This script is slightly unusual in that the name of the daemon (postmaster)
|
|
||||||
# is not the same as the name of the subsystem (postgresql)
|
|
||||||
|
|
||||||
# See how we were called.
|
# See how we were called.
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
@ -293,21 +224,21 @@ case "$1" in
|
|||||||
restart)
|
restart)
|
||||||
restart
|
restart
|
||||||
;;
|
;;
|
||||||
condrestart)
|
condrestart|try-restart)
|
||||||
condrestart
|
condrestart
|
||||||
;;
|
;;
|
||||||
condstop)
|
reload)
|
||||||
condstop
|
|
||||||
;;
|
|
||||||
reload|force-reload)
|
|
||||||
reload
|
reload
|
||||||
;;
|
;;
|
||||||
|
force-reload)
|
||||||
|
restart
|
||||||
|
;;
|
||||||
initdb)
|
initdb)
|
||||||
initdb
|
initdb
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo $"Usage: $0 {start|stop|status|restart|condrestart|condstop|reload|force-reload|initdb}"
|
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|initdb}"
|
||||||
exit 1
|
exit 2
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit $script_result
|
exit $script_result
|
||||||
|
@ -53,7 +53,7 @@ Summary: PostgreSQL client programs
|
|||||||
Name: postgresql
|
Name: postgresql
|
||||||
%global majorversion 8.4
|
%global majorversion 8.4
|
||||||
Version: 8.4.2
|
Version: 8.4.2
|
||||||
Release: 7%{?dist}
|
Release: 8%{?dist}
|
||||||
# The PostgreSQL license is very similar to other MIT licenses, but the OSI
|
# The PostgreSQL license is very similar to other MIT licenses, but the OSI
|
||||||
# recognizes it as an independent license, so we do as well.
|
# recognizes it as an independent license, so we do as well.
|
||||||
License: PostgreSQL
|
License: PostgreSQL
|
||||||
@ -170,10 +170,13 @@ PostgreSQL server.
|
|||||||
%package server
|
%package server
|
||||||
Summary: The programs needed to create and run a PostgreSQL server
|
Summary: The programs needed to create and run a PostgreSQL server
|
||||||
Group: Applications/Databases
|
Group: Applications/Databases
|
||||||
Requires: postgresql = %{version}-%{release}
|
Requires: %{name} = %{version}-%{release}
|
||||||
Requires(pre): /usr/sbin/useradd
|
Requires(pre): /usr/sbin/useradd
|
||||||
Requires(post): /sbin/chkconfig
|
Requires(post): chkconfig
|
||||||
Requires(preun): /sbin/chkconfig
|
Requires(preun): chkconfig
|
||||||
|
# This is for /sbin/service
|
||||||
|
Requires(preun): initscripts
|
||||||
|
Requires(postun): initscripts
|
||||||
|
|
||||||
%description server
|
%description server
|
||||||
The postgresql-server package includes the programs needed to create
|
The postgresql-server package includes the programs needed to create
|
||||||
@ -492,18 +495,18 @@ cat psql-%{majorversion}.lang >>main.lst
|
|||||||
%postun libs -p /sbin/ldconfig
|
%postun libs -p /sbin/ldconfig
|
||||||
|
|
||||||
%pre server
|
%pre server
|
||||||
groupadd -g 26 -o -r postgres >/dev/null 2>&1 || :
|
/usr/sbin/groupadd -g 26 -o -r postgres >/dev/null 2>&1 || :
|
||||||
useradd -M -N -g postgres -o -r -d /var/lib/pgsql -s /bin/bash \
|
/usr/sbin/useradd -M -N -g postgres -o -r -d /var/lib/pgsql -s /bin/bash \
|
||||||
-c "PostgreSQL Server" -u 26 postgres >/dev/null 2>&1 || :
|
-c "PostgreSQL Server" -u 26 postgres >/dev/null 2>&1 || :
|
||||||
|
|
||||||
%post server
|
%post server
|
||||||
chkconfig --add postgresql
|
/sbin/chkconfig --add postgresql
|
||||||
/sbin/ldconfig
|
/sbin/ldconfig
|
||||||
|
|
||||||
%preun server
|
%preun server
|
||||||
if [ $1 = 0 ] ; then
|
if [ $1 = 0 ] ; then
|
||||||
/sbin/service postgresql condstop >/dev/null 2>&1
|
/sbin/service postgresql stop >/dev/null 2>&1
|
||||||
chkconfig --del postgresql
|
/sbin/chkconfig --del postgresql
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%postun server
|
%postun server
|
||||||
@ -711,6 +714,10 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Feb 22 2010 Tom Lane <tgl@redhat.com> 8.4.2-8
|
||||||
|
- Bring init script into some modicum of compliance with Fedora/LSB standards
|
||||||
|
Resolves: #201043
|
||||||
|
|
||||||
* Thu Feb 18 2010 Tom "spot" Callaway <tcallawa@redhat.com> 8.4.2-7
|
* Thu Feb 18 2010 Tom "spot" Callaway <tcallawa@redhat.com> 8.4.2-7
|
||||||
- adjust license tag to reflect OSI decision
|
- adjust license tag to reflect OSI decision
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user