Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Locate the data directory for PostgreSQL on FreeBSD
$ ./get_postgresql_data
/var/db/postgres/data12
!/bin/sh
CONFIGURED=`sysrc -qn postgresql_data`
if [ "$?" == "1" ]; then
VERSION=`pkg info | grep -i 'PostgreSQL database' | cut -b 11,12`
if [ "$VERSION" == "" ]; then
# we have nothing
exit 1
fi
CONFIGURED="/var/db/postgres/data$VERSION"
fi
echo $CONFIGURED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.