~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to contrib/start-scripts/linux

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
3
# chkconfig: 2345 98 02
 
4
# description: PostgreSQL RDBMS
 
5
 
 
6
# This is an example of a start/stop script for SysV-style init, such
 
7
# as is used on Linux systems.  You should edit some of the variables
 
8
# and maybe the 'echo' commands.
 
9
#
 
10
# Place this file at /etc/init.d/postgresql (or
 
11
# /etc/rc.d/init.d/postgresql) and make symlinks to
 
12
#   /etc/rc.d/rc0.d/K02postgresql
 
13
#   /etc/rc.d/rc1.d/K02postgresql
 
14
#   /etc/rc.d/rc2.d/K02postgresql
 
15
#   /etc/rc.d/rc3.d/S98postgresql
 
16
#   /etc/rc.d/rc4.d/S98postgresql
 
17
#   /etc/rc.d/rc5.d/S98postgresql
 
18
# Or, if you have chkconfig, simply:
 
19
# chkconfig --add postgresql
 
20
#
 
21
# Proper init scripts on Linux systems normally require setting lock
 
22
# and pid files under /var/run as well as reacting to network
 
23
# settings, so you should treat this with care.
 
24
 
 
25
# Original author:  Ryan Kirkpatrick <pgsql@rkirkpat.net>
 
26
 
 
27
# $PostgreSQL$
 
28
 
 
29
## EDIT FROM HERE
 
30
 
 
31
# Installation prefix
 
32
prefix=/usr/local/pgsql
 
33
 
 
34
# Data directory
 
35
PGDATA="/usr/local/pgsql/data"
 
36
 
 
37
# Who to run the postmaster as, usually "postgres".  (NOT "root")
 
38
PGUSER=postgres
 
39
 
 
40
# Where to keep a log file
 
41
PGLOG="$PGDATA/serverlog"
 
42
 
 
43
## STOP EDITING HERE
 
44
 
 
45
# The path that is to be used for the script
 
46
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
47
 
 
48
# What to use to start up the postmaster (we do NOT use pg_ctl for this,
 
49
# as it adds no value and can cause the postmaster to misrecognize a stale
 
50
# lock file)
 
51
DAEMON="$prefix/bin/postmaster"
 
52
 
 
53
# What to use to shut down the postmaster
 
54
PGCTL="$prefix/bin/pg_ctl"
 
55
 
 
56
set -e
 
57
 
 
58
# Only start if we can find the postmaster.
 
59
test -x $DAEMON || exit 0
 
60
 
 
61
# Parse command line parameters.
 
62
case $1 in
 
63
  start)
 
64
        echo -n "Starting PostgreSQL: "
 
65
        su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
 
66
        echo "ok"
 
67
        ;;
 
68
  stop)
 
69
        echo -n "Stopping PostgreSQL: "
 
70
        su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"
 
71
        echo "ok"
 
72
        ;;
 
73
  restart)
 
74
        echo -n "Restarting PostgreSQL: "
 
75
        su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
 
76
        su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
 
77
        echo "ok"
 
78
        ;;
 
79
  reload)
 
80
        echo -n "Reload PostgreSQL: "
 
81
        su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"
 
82
        echo "ok"
 
83
        ;;
 
84
  status)
 
85
        su - $PGUSER -c "$PGCTL status -D '$PGDATA'"
 
86
        ;;
 
87
  *)
 
88
        # Print help
 
89
        echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2
 
90
        exit 1
 
91
        ;;
 
92
esac
 
93
 
 
94
exit 0