Re: Init script

From: "Lane Van Ingen" <lvaningen(at)esncc(dot)com>
To: "Andrej Ricnik-Bay" <andrej(dot)groups(at)gmail(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Init script
Date: 2005-09-23 20:17:04
Message-ID: EKEMKEFLOMKDDLIALABIGEOOCCAA.lvaningen@esncc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

This one works for us ....

#!/bin/sh
# Start/stop/restart postgresql.
#
# To start PostgreSQL automatically at boot, be sure this script is
executable:
# chmod 755 /etc/rc.d/rc.postgres

# --> Before you can run PostgreSQL, you must have a database. Use initd.
#
# Note that step one is becoming the 'postgres' user. It's important to do
this
# before making any changes to the database, or postgres won't be able to
write
# to it later

# Set up variables
PGROOT=/usr/local/pgsql
PGDATA=/usr/local/pgsql/data
PGUSER=postgres
PGLOG="$PGDATA/postgres.log"
PGDAEMON="$PGROOT/bin/postmaster"
PGCTL="$PGROOT/bin/pg_ctl"

if echo '\c' | grep -s c >/dev/null 2>%1; then
ECHO_N="echo -n"
ECHO_C=""
else
ECHO_N="echo"
ECHO_C='\c'
fi

set -e

# Start postgresql:
postgresql_start() {
$ECHO_N "Starting PostgreSQL: "$ECHO_C
su - $PGUSER -c "$PGDAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
}

# Stop postgresql:
postgresql_stop() {
$ECHO_N "Stopping PostgreSQL: "$ECHO_C
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast" >>$PGLOG 2>&1
echo "ok"
}

# Restart postgreSQL:
postgresql_restart() {
$ECHO_N "Restarting PostgreSQL: "$ECHO_C
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast" >>$PGLOG 2>&1
echo "ok"
su - $PGUSER -c "$PGDAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
}

case "$1" in
'start')
postgresql_start
;;
'stop')
postgresql_stop
;;
'restart')
postgresql_restart
;;
*)
echo "Usage $0 {start|stop|restart}" 1>&2
exit 1
;;
esac
exit 0

-----Original Message-----
From: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org]On Behalf Of Andrej Ricnik-Bay
Sent: Friday, September 23, 2005 2:19 PM
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: [NOVICE] Init script

On 9/24/05, Marc Khayat <marc(at)globalcarrier(dot)net> wrote:
> Anyone can provide the init script (that resides in /etc/rc.d/ini.t) for
> Postgresql-8.0.3? it's installed in /usr/local/pgsql
Can't you find the one from your RPM?

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Wayne Unruh 2005-09-24 06:45:45 Re: Primary and Foreign Key?
Previous Message Andrej Ricnik-Bay 2005-09-23 18:18:58 Re: Init script