Forum OpenACS Q&A: Help with starting postgres after the rebooting of a Solaris machine

Here is my /etc/init.d/postgres


#!/bin/sh
# PostgreSQL

case "$1" in
'start')
 su - postgres -c "/usr/local/pgsql/bin/pg_ctl -D 
/usr/local/pgsql/data start"
 ;;
'stop')
 su - postgres -c "/usr/local/pgsql/bin/pg_ctl -D 
/usr/local/pgsql/data stop"
 ;;
*)
 echo "Usage: $0 { start | stop }"
 ;;
esac
exit 0


When I do /etc/init.d/postgres start as a 
root, I get:

ld.so.1: /usr/local/pgsql/bin/postmaster: fatal: libz.so: open 
failed: No such file
or directory
548 Killed
postmaster successfully started


And, when I do psql testdb as postgres, I 
get:

psql: connectDBStart() -- connect() failed: No such file or directory
        Is the postmaster running locally
        and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?

But, when I do /usr/local/pgsql/bin/pg_ctl -D 
/usr/local/pgsql/data start as
postgres, everything works fine.

env gives same for both root and 
postgres:


PWD=/export/home/postgres
TZ=US/Pacific
HZ=100
HOSTNAME=my_host_name
LD_LIBRARY_PATH=/usr/lib/:/usr/local/lib:/usr/local/pgsql/lib
MANPATH=:/usr/local/pgsql/man
MACHTYPE=sparc-sun-solaris2.7
WAS_DIR=/opt/WebSphere/AppServer
DISPLAY=10.209.70.125:0.0
LOGNAME=postgres
SHLVL=1
SHELL=/usr/local/bin/bash
HOSTTYPE=sparc
CVSROOT=/usr/local/cvsroot
OSTYPE=solaris2.7
HOME=/export/home/postgres
TERM=vt100
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr
/X/bin:/usr/ccs/bin:/usr/local/pgsql/bin

_=/bin/env


What could be the problem, please?

Your help is appreciated so much.
The problem solved by explicitly defining LD_LIBRARY_PATH in the command line i.e.


su - postgres -c "export LD_LIBRARY_PATH=/usr/lib/:/usr/local/lib:/usr/local/pgsql/lib ; /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data start"

Best Regards,