Skip to content

Instantly share code, notes, and snippets.

@dlangille
Created December 10, 2019 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlangille/b67a08be9a7eb360f9ab696b56a2d586 to your computer and use it in GitHub Desktop.
Save dlangille/b67a08be9a7eb360f9ab696b56a2d586 to your computer and use it in GitHub Desktop.
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