#!/bin/sh -x # # this script is /etc/init.d/postgresql # # this script should be linked to the following startup files, like # this: # 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 B=/usr/local/pgsql/bin D=/disk/a/pgsql L=logfile PGUSER=postgres if [ ! -d ${B} ]; then # /usr not mounted exit 0 fi # Start/stop processes required for PostgreSQL case "$1" in 'start') if [ -d ${D} ]; then # stupid log rolling... if [ -f ${D}/${L}.5 ]; then mv ${D}/${L}.5 ${D}/${L}.6 fi if [ -f ${D}/${L}.4 ]; then mv ${D}/${L}.4 ${D}/${L}.5 fi if [ -f ${D}/${L}.3 ]; then mv ${D}/${L}.3 ${D}/${L}.4 fi if [ -f ${D}/${L}.2 ]; then mv ${D}/${L}.2 ${D}/${L}.3 fi if [ -f ${D}/${L}.1 ]; then mv ${D}/${L}.1 ${D}/${L}.2 fi if [ -f ${D}/${L}.0 ]; then mv ${D}/${L}.0 ${D}/${L}.1 fi su - ${PGUSER} -c "cd ${D} && ${B}/postmaster -D ${D} > ${L}.0 2>&1 &" fi ;; 'stop') /usr/bin/pkill -u ${PGUSER} -o ;; *) echo "Usage: $0 { start | stop }" ;; esac