# fss-0002

#### What to do to get PostrgreSQL running after install:
## The first one should be switch to the t_database user
  #su - t_database -c '/bin/initdb -D /home/targets/database/data -E UTF8 --locale=en_US.UTF-8'
  #su - t_database -c '/bin/postmaster -D /home/targets/database/data -E UTF8 --locale=en_US.UTF-8 &'
  #su - t_database -c 'sleep 7 ; /bin/createdb test'
  #su - t_database -c '/sbin/pg_ctl -D/home/targets/database/data -s -m fast stop'

# Creating a user:
  # createuser --pwprompt --encrypted --no-adduser --no-createdb username

# Creating a table:
  # createdb --encoding=UNICODE --owner=username databasename

main:
  if [[ $(grep -m 1 -o '^t_database:[^:]*:' /etc/passwd) == "" ]] ; then adduser -l /bin/bash -t target -g t_database -n database ; fi
  sed -i -e 's|@PTHREAD_CFLAGS@|& -pthread|g' src/Makefile.global.in
  export old_flags="$CFLAGS"
  ./configure $CONF $DOCDIR --without-perl --without-tcl --without-pam --with-openssl --with-libxml --with-libxslt --enable-thread-safety --with-ldap CFLAGS="$CFLAGS -fstack-protector"
  make
  make install
  export CFLAGS="$old_flags"
  unset old_flags
  cp -v ${PR}postgresql.conf /home/targets/database/settings/
  mv -v /bin/pg_ctl /sbin/
  chgrp -R e_postgres /lib/postgresql /share/postgresql /lib/lib{ecpg,ecpg_compat,pgtypes,pq}.so* /bin/{clusterdb,createdb,createlang,createuser,dropdb,droplang,ecpg,initdb,pg_config,pg_controldata,pg_dump,pg_dumpall,pg_restore,postgres,psql,reindexdb,vacuumdb,dropuser,pg_resetxlog}
  chgrp d_toolchain /bin/pg_config
  mv -v /bin/pg_config ${TC}bin/
  chgrp -R t_database /sbin/pg_ctl
  if [[ -f /bin/pg_basebackup ]] ; then chgrp e_postgres /bin/pg_basebackup ; fi
  rm -Rf /lib/lib{ecpg,ecpg_compat,pgport,pgtypes,pq}.a
  tkis_handle_documentation html servers /doc/postgres
  rm -Rf /doc
