Solve stale-lockfile problem; use runuser instead of su.
This commit is contained in:
parent
0c2148cdc2
commit
3fd417a317
@ -56,6 +56,11 @@
|
||||
# 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.
|
||||
|
||||
|
||||
# PGVERSION is:
|
||||
PGVERSION=7.4
|
||||
@ -77,6 +82,14 @@ then
|
||||
NAME=${NAME:3}
|
||||
fi
|
||||
|
||||
# For SELinux we need to use 'runuser' not 'su'
|
||||
if [ -x /sbin/runuser ]
|
||||
then
|
||||
SU=runuser
|
||||
else
|
||||
SU=su
|
||||
fi
|
||||
|
||||
|
||||
# Set defaults for configuration variables
|
||||
PGENGINE=/usr/bin
|
||||
@ -157,45 +170,34 @@ start(){
|
||||
[ -f /etc/sysconfig/i18n ] && cp /etc/sysconfig/i18n $PGDATA/../initdb.i18n
|
||||
# Just in case no locale was set, use en_US
|
||||
[ ! -f /etc/sysconfig/i18n ] && echo "LANG=en_US" > $PGDATA/../initdb.i18n
|
||||
# Is expanded this early to be used in the command su runs
|
||||
# Is expanded this early to be used in the command $SU runs
|
||||
echo "export LANG LC_ALL LC_CTYPE LC_COLLATE LC_NUMERIC LC_CTYPE LC_TIME" >> $PGDATA/../initdb.i18n
|
||||
# Initialize the database
|
||||
su -l postgres -c "$PGENGINE/initdb --pgdata=$PGDATA" >> $PGLOG 2>&1 < /dev/null
|
||||
$SU -l postgres -c "$PGENGINE/initdb --pgdata=$PGDATA" >> $PGLOG 2>&1 < /dev/null
|
||||
[ -f $PGDATA/PG_VERSION ] && echo_success
|
||||
[ ! -f $PGDATA/PG_VERSION ] && echo_failure
|
||||
echo
|
||||
fi
|
||||
|
||||
# Check for postmaster already running...
|
||||
# note that pg_ctl only looks at the data structures in PGDATA
|
||||
# you really do need the pidof()
|
||||
echo -n "$PSQL_START"
|
||||
$SU -l postgres -c "$PGENGINE/postmaster -p ${PGPORT} -D '${PGDATA}' ${PGOPTS} &" >> $PGLOG 2>&1 < /dev/null
|
||||
sleep 1
|
||||
pid=`pidof -s $PGENGINE/postmaster`
|
||||
if [ $pid ] && $PGENGINE/pg_ctl status -D $PGDATA > /dev/null 2>&1
|
||||
if [ $pid ] && [ -f "${PGDATA}/postmaster.pid" ]
|
||||
then
|
||||
echo $"Postmaster already running."
|
||||
success "$PSQL_START"
|
||||
touch /var/lock/subsys/${NAME}
|
||||
head -n 1 "${PGDATA}/postmaster.pid" > /var/run/postmaster.${PGPORT}.pid
|
||||
echo
|
||||
else
|
||||
#all systems go -- remove any stale lock files
|
||||
rm -f /tmp/.s.PGSQL.${PGPORT} > /dev/null
|
||||
echo -n "$PSQL_START"
|
||||
su -l postgres -c "$PGENGINE/pg_ctl -D $PGDATA -p $PGENGINE/postmaster -o '-p ${PGPORT} ${PGOPTS}' start" >> $PGLOG 2>&1 < /dev/null
|
||||
sleep 1
|
||||
pid=`pidof -s $PGENGINE/postmaster`
|
||||
if [ $pid ]
|
||||
then
|
||||
success "$PSQL_START"
|
||||
touch /var/lock/subsys/${NAME}
|
||||
echo $pid > /var/run/postmaster.${PGPORT}.pid
|
||||
echo
|
||||
else
|
||||
failure "$PSQL_START"
|
||||
echo
|
||||
fi
|
||||
failure "$PSQL_START"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
stop(){
|
||||
echo -n $"Stopping ${NAME} service: "
|
||||
su -l postgres -c "$PGENGINE/pg_ctl stop -D $PGDATA -s -m fast" > /dev/null 2>&1 < /dev/null
|
||||
$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
|
||||
@ -222,7 +224,7 @@ condstop(){
|
||||
}
|
||||
|
||||
reload(){
|
||||
su -l postgres -c "$PGENGINE/pg_ctl reload -D $PGDATA -s" > /dev/null 2>&1 < /dev/null
|
||||
$SU -l postgres -c "$PGENGINE/pg_ctl reload -D '${PGDATA}' -s" > /dev/null 2>&1 < /dev/null
|
||||
}
|
||||
|
||||
# This script is slightly unusual in that the name of the daemon (postmaster)
|
||||
@ -257,4 +259,3 @@ case "$1" in
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
|
@ -67,7 +67,7 @@ Version: 7.4.5
|
||||
# Pre-release RPM's should not be put up on the public ftp.postgresql.org server
|
||||
# -- only test releases or full releases should be.
|
||||
|
||||
Release: 2
|
||||
Release: 3
|
||||
License: BSD
|
||||
Group: Applications/Databases
|
||||
Source0: ftp://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2
|
||||
@ -84,6 +84,7 @@ Source18: ftp://ftp.druid.net/pub/distrib/PyGreSQL-3.5.tgz
|
||||
Patch1: rpm-pgsql-7.4.patch
|
||||
Patch2: rpm-multilib-%{version}.patch
|
||||
Patch3: postgresql-7.4-tighten.patch
|
||||
Patch4: postgresql-7.4-getppid.patch
|
||||
Patch5: postgresql-plperl.patch
|
||||
Patch6: postgresql-7.4-src-tutorial.patch
|
||||
Patch7: postgresql-7.3.4-s390-pic.patch
|
||||
@ -331,7 +332,7 @@ popd
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
# %patch4 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
%patch6 -p1
|
||||
%patch7 -p1
|
||||
@ -784,6 +785,10 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Oct 05 2004 Tom Lane <tgl@redhat.com> 7.4.5-3
|
||||
- Solve the stale lockfile problem (bugs 71295, 96981, 134090)
|
||||
- Use runuser instead of su for SELinux (bug 134588)
|
||||
|
||||
* Mon Aug 30 2004 Tom Lane <tgl@redhat.com> 7.4.5-2
|
||||
- Update to PyGreSQL 3.5.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user