ports/databases/postgresql84-server/files/pkg-install-server.in
Chris Rees c413f3f468 Revert previous commit -- appears to cause rc problems as I missed some subs
http://www.mail-archive.com/freebsd-ports@freebsd.org/msg35324.html

PR:		ports/157558 ports/157559 ports/157666 ports/157669
Submitted by:	rihad@mail.ru
Approved by:	maintainer (girgen; implicit -- this reverts a commit I did after maintainer timeout)
2011-08-15 14:52:31 +00:00

63 lines
1.3 KiB
Bash

#! /bin/sh
# $FreeBSD$
PATH=/bin:/usr/bin:/usr/sbin
PG_USER=%%PG_USER%%
PG_GROUP=%%PG_GROUP%%
PG_UID=%%PG_UID%%
backupwarning() { echo "
=========== BACKUP YOUR DATA! =============
As always, backup your data before
upgrading. If the upgrade leads to a higher
minor revision (e.g. 7.3.x -> 7.4), a dump
and restore of all databases is
required. This is *NOT* done by the port!
Press ctrl-C *now* if you need to pg_dump.
===========================================
"
sleep 5
}
case $2 in
PRE-INSTALL)
backupwarning
DB_DIR=${PKG_PREFIX}/${PG_USER}
if pw group show "${PG_GROUP}" 2>/dev/null; then
echo "You already have a group \"${PG_GROUP}\", so I will use it."
else
if pw groupadd ${PG_GROUP} -g ${PG_UID}; then
echo "Added group \"${PG_GROUP}\"."
else
echo "Adding group \"${PG_GROUP}\" failed..."
exit 1
fi
fi
if pw user show "${PG_USER}" 2>/dev/null; then
echo "You already have a user \"${PG_USER}\", so I will use it."
else
if pw useradd ${PG_USER} -u ${PG_UID} -g ${PG_GROUP} -h - \
-d ${DB_DIR} -c "PostgreSQL Daemon"
then
echo "Added user \"${PG_USER}\"."
else
echo "Adding user \"${PG_USER}\" failed..."
exit 1
fi
fi
if ! [ -x ~${PG_USER} ] ; then
install -m 755 -o ${PG_USER} -g ${PG_GROUP} -d ${DB_DIR}
fi
;;
BACKUPWARNING)
backupwarning
;;
esac