postgresqlの自動起動について

/etc/init.d/ の配下に以下のようなファイルを作成する。

// ファイルの作成
# vi postgres

// ファイルの内容

#!/bin/sh
#
# PostgreSQL start and shutdown script
#
# chkconfig: 345 90 11
# description: PostgreSQL start and shutdown script

PGACCOUNT="postgres"
PGDATA="/usr/local/pgsql/data"
POSTMASTER="/usr/local/pgsql/bin/postmaster"
PG_CTL="/usr/local/pgsql/bin/pg_ctl"

. /etc/init.d/functions

case "$1" in
 start)
   su - $PGACCOUNT -c "$POSTMASTER -D $PGDATA &"
   touch /var/lock/subsys/postgres
   ;;
 stop)
   su - $PGACCOUNT -c "$PG_CTL stop -D $PGDATA"
   rm -f /var/lock/subsys/postgres
   ;;
 *)
   echo "Usage: /etc/rc.d/init.d/postgres  {start|stop}"
esac

exit 0

// chkconfig でサービス登録
#chkconfig --add postgres