#!/bin/bash
#  $Id$
# -----------------------------------------------------------------------------
#  Name:    db_restart
#  Purpose: unified database restart (Linux version)
#
#  Note:    started from install.root deinstall.root
#
# -----------------------------------------------------------------------------
#  Author: Alexei Titov
#  Edited by: Alexey Tsibulnik
#  QA by:  Christopher C Gettings
#  Copyright: videoNEXT LLC
# -----------------------------------------------------------------------------

PG_PATH=/var/lib/pgsql/data
if [ -f $PG_PATH/PG_VERSION ]; then 
   /sbin/service postgresql stop
   ret=$? 
   if [ $ret -ne 0 ]
   then 
        su postgres -lc "/usr/bin/pg_ctl stop -m immediate"
   fi
else
   # database is not exist yet (stgresql84)
   /sbin/service postgresql initdb
fi
/sbin/service postgresql start

