openbsd-ports/databases/postgresql/pkg/INSTALL-server

61 lines
1.3 KiB
Bash

#!/bin/sh
#
# $OpenBSD: INSTALL-server,v 1.2 2004/10/12 21:03:13 espie Exp $
#
# Pre/post-installation setup of postgresql
# use a sane path and install prefix
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PREFIX=${PKG_PREFIX:-/usr/local}
PGHOME=/var/postgresql
PG=_postgresql
do_initdb()
{
install -d -o $PG -g $PG -m 0755 $PGHOME
if [ ! -d $PGHOME/data ]; then
echo
echo "+---------------------"
echo "| Creating default database installation in:"
echo "|"
echo "| $PGHOME/data"
echo "+---------------------"
echo
install -d -o $PG -g $PG -m 0775 $PGHOME/data
su $PG -c "$PREFIX/bin/initdb -D $PGHOME/data"
echo
else
echo
echo "+---------------------"
echo "| Leaving existing database installation in:"
echo "|"
echo "| $PGHOME/data"
echo "|"
echo "| Note that any previous database files are UNLIKELY to"
echo "| be compatible with upgraded versions of $1"
echo "| package."
echo "|"
echo "| DO NOT just try to start the database unless you"
echo "| are absolutely sure that the existing files are"
echo "| compatible with this version of $1."
echo "|"
echo "| See the $1 documentation and/or"
echo "| $PREFIX/share/doc/postgresql/README.OpenBSD for"
echo "| more information."
echo "+---------------------"
echo
fi
}
# Verify/process the command
#
case $2 in
POST-INSTALL)
do_initdb $1
;;
esac
exit 0