Skip to content

Instantly share code, notes, and snippets.

@farhaven
Last active April 8, 2016 12:52
Show Gist options
  • Save farhaven/71683fdfa78efc4ea1832c3ec80da6e3 to your computer and use it in GitHub Desktop.
Save farhaven/71683fdfa78efc4ea1832c3ec80da6e3 to your computer and use it in GitHub Desktop.
#!/bin/ksh
echo "=> Setting up PostgreSQL..."
#
# Replace this currently running script by a shell running the same command,
# only as the user _postgresql
#
# -c : Run the rest of the commandline as if it were entered in there
# $@ : complete commandline passed to the script, including its name
if [ `whoami` == "root" ]; then
exec su -l -s /bin/sh _postgresql -c "/bin/sh -c $0 $@"
fi
mkdir /var/postgresql/data/
initdb -D /var/postgresql/data -U postgres -E UTF8 -A md5 -W
echo "=> PostgreSQL setup complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment