#!/bin/sh
if [ $(id -u) -ne 0 ]; then
  echo "you must be root"
  exit 1
fi
. /etc/postgresd.conf
grep -q "^$PGGROUP:" /etc/group
if [ $? -ne 0 ]; then
  groupadd -g 209 $PGGROUP
fi
grep -q "^$PGUSER:" /etc/passwd
if [ $? -ne 0 ]; then
  useradd -u 209 -d $PGHOME -m -k /dev/null -g $PGGROUP $PGUSER
fi
chmod u=rwx,go= $PGHOME
su - $PGUSER -c "initdb -D $PGDB"
