#!/bin/sh 

if [ "$USER" != "postgres" ]; then
  echo "$0 must be run by postgres"
fi
echo "Initializing default data base by user $USER ..."

cd

PG_ROOT=/opt/pgsql
PATH=$PATH:$PG_ROOT/bin
PGLIB=$PG_ROOT/lib
PGDATA=$PG_ROOT/data
LD_LIBRARY_PATH=$PGLIB
export PATH PGLIB PGDATA LD_LIBRARY_PATH

echo "running... createdb postgres"
createdb postgres

#echo "running... pg_passwd $PGDATA/pgpasswd"
#pg_passwd $PGDATA/pgpasswd

echo "running... createuser www with 7.2 createuser command" 
createuser www<<EOS1
n
n
EOS1
createuser wadm<<EOS2
y
y
EOS2


# create user www from web access
createdb www

# update .cshrc.mine for users
cp -f $PG_ROOT/apps/_cshrc.pgsqlj $PG_ROOT/.cshrc.mine 
