Sophie

Sophie

distrib > PLD > ac > amd64 > by-pkgid > 2dc0458687b1014918c93e2b3a62edba > scriptlet

postgresql-8.2.3-1.amd64.rpm

PREIN

/bin/sh
PG_DB_CLUSTERS=""
if [ -f /etc/sysconfig/postgresql ]; then
	. /etc/sysconfig/postgresql
	if [ -z "$PG_DB_CLUSTERS" -a -n "$POSTGRES_DATA_DIR" ]; then
		PG_DB_CLUSTERS="$POSTGRES_DATA_DIR"
	fi
fi
foundold=0
for pgdir in $PG_DB_CLUSTERS; do
	if [ -f $pgdir/PG_VERSION ]; then
		if [ `cat $pgdir/PG_VERSION` != '8.2' ]; then
			echo "Found database(s) in older, incompatible format in cluster $pgdir."
			foundold=1
		fi
	fi
done
if [ "$foundold" = "1" ]; then
	echo
	echo "Dump all data from clusters mentioned above (using pg_dump or pg_dumpall)"
	echo "and clean (or rename) those directories; then upgrade postgresql and"
	echo "restore all data (using pg_restore or psql)."
	echo "Remember to stop the daemon before upgrading!"
	echo
	echo "Warning for upgrade from version *before* 7.2."
	echo "Please note, that postgresql module path changed from"
	echo "/usr/lib/pgsql/module to /usr/lib/postgresql. Change the path"
	echo "in dump file before restore."
	echo
	echo "Warning for upgrade from version *before* 7.3."
	echo "Reading following webpage is encouraged:"
	echo "http://www.ca.postgresql.org/docs/momjian/upgrade_tips_7.3"
	exit 1
fi


 
 
if [ -n "`/usr/bin/getgid postgres`" ]; then 
	if [ "`/usr/bin/getgid postgres`" != "88" ]; then 
		echo "Error: group postgres doesn't have gid=88. Correct this before installing postgresql." 1>&2 
		exit 1 
	fi 
else 
	echo "Adding group postgres GID=88." 
	/usr/sbin/groupadd -g 88 -r postgres 1>&2 || exit $? 
	[ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group || : 
fi;
 
 
 
if [ -n "`/bin/id -u postgres 2>/dev/null`" ]; then 
	if [ "`/bin/id -u postgres`" != "88" ]; then 
		echo "Error: user postgres doesn't have uid=88. Correct this before installing postgresql." 1>&2 
		exit 1 
	fi 
else 
	echo "Adding user postgres UID=88." 
	/usr/sbin/useradd \
		 \
		-u 88 \
		-r \
		-d /home/services/postgres \
		-s /bin/sh \
		-c "PostgreSQL Server"\
		-g postgres \
		-M \
		 \
		postgres 1>&2 || exit $? 
	[ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd || : 
fi;
if [ -n "`/bin/id -u postgres 2>/dev/null`" ]; then
	/usr/sbin/usermod -d /home/services/postgres postgres
fi

PREUN

/bin/sh
if [ "$1" = "0" ]; then
	{
if [ -f /var/lock/subsys/postgresql ]; then
/sbin/service postgresql stop 1>&2 || :;
fi };	/sbin/chkconfig --del postgresql
fi

POSTIN

/bin/sh
/sbin/chkconfig --add postgresql
{
skip_auto_restart() {
[ -f /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm
[ -f /etc/sysconfig/postgresql ] && . /etc/sysconfig/postgresql
echo ${RPM_SKIP_AUTO_RESTART:-no}
};
if [ $(skip_auto_restart) = no ]; then
if [ -f /var/lock/subsys/postgresql ]; then
/sbin/service postgresql restart 1>&2 || :;
else
echo 'Run "/sbin/service postgresql start" to start postgresql server.'
fi
fi };