Friday, July 4, 2008

Create startup script for postgresql on solaris

Here is simple script postgresql 8.2(startup on solaris)
Create file in /etc/init.d with name postgresql


#!/sbin/sh
#change with your prefix installation
PGBIN=/usr/postgres/8.2/bin
PGDATA=/export/postgres82/pgdata
PGLOG=/export/postgres82/pgdata/log
PGUSER=postgres
case "$1" in
'start')
su - $PGUSER -c "$PGBIN/pg_ctl -D $PGDATA start"
;;

'stop')
su - $PGUSER -c "$PGBIN/pg_ctl -D $PGDATA stop"
;;

'refresh')
su - $PGUSER "$PGBIN/pg_ctl -D $PGDATA reload"
;;
*)

echo $"Usage: $0 {start|refresh}"
exit 1
;;

esac

change file permission to 755
then you have to make link to other directory.
#ln /etc/init.d/postgresql /etc/rc0.d/K03postgresql
#ln /etc/init.d/postgresql /etc/rc1.d/K03postgresql
#ln /etc/init.d/postgresql /etc/rc2.d/K03postgresql
#ln /etc/init.d/postgresql /etc/rcS.d/K03postgresql
#ln /etc/init.d/postgresql /etc/rc3.d/S90postgresql

Try to start stop service and restart the system.
check with
# ps -ef | grep post
postgres 736 734 0 15:47:00 ? 0:00 /usr/postgres/8.2/bin/postgres -D /export/postgres82/pgdata
root 739 711 0 15:49:13 pts/2 0:00 grep post
postgres 734 1 0 15:47:00 pts/2 0:00 /usr/postgres/8.2/bin/postgres -D /export/postgres82/pgdata
postgres 737 734 0 15:47:00 ? 0:00 /usr/postgres/8.2/bin/postgres -D /export/postgres82/pgdata
#
Finish

No comments:

Post a Comment