diff options
Diffstat (limited to 'databases/postgresql84-server/files/pkg-install-server.in')
-rw-r--r-- | databases/postgresql84-server/files/pkg-install-server.in | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/databases/postgresql84-server/files/pkg-install-server.in b/databases/postgresql84-server/files/pkg-install-server.in new file mode 100644 index 000000000000..a9651cfa6156 --- /dev/null +++ b/databases/postgresql84-server/files/pkg-install-server.in @@ -0,0 +1,66 @@ +#! /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 + PGUSER=${PGUSER:-${PG_USER}} + PGGROUP=${PGGROUP:-${PG_GROUP}} + DB_DIR=${PKG_PREFIX}/${PG_USER} + UID=${PG_UID} + GID=${PG_UID} + + if pw group show "${PGGROUP}" 2>/dev/null; then + echo "You already have a group \"${PGGROUP}\", so I will use it." + else + if pw groupadd ${PGGROUP} -g ${GID}; then + echo "Added group \"${PGGROUP}\"." + else + echo "Adding group \"${PGGROUP}\" failed..." + exit 1 + fi + fi + + if pw user show "${PGUSER}" 2>/dev/null; then + echo "You already have a user \"${PGUSER}\", so I will use it." + else + if pw useradd ${PGUSER} -u ${UID} -g ${PGGROUP} -h - \ + -d ${DB_DIR} -c "PostgreSQL Daemon" + then + echo "Added user \"${PGUSER}\"." + else + echo "Adding user \"${PGUSER}\" failed..." + exit 1 + fi + fi + + if ! [ -x ~${PGUSER} ] ; then + install -m 755 -o ${PGUSER} -g ${PGGROUP} -d ${DB_DIR} + fi + ;; + +BACKUPWARNING) + backupwarning + ;; +esac |