|
1 | 1 | #! /bin/sh
|
2 | 2 | #
|
3 |
| -# PostgreSQLStart the pgsql RDMBS. |
| 3 | +# PostgreSQLStart, stop, and get status on the PostgreSQL RDMBS. |
| 4 | +# This script is Linux distribution independent |
| 5 | +# (or at least should be :). |
| 6 | +# |
| 7 | +# By Ryan Kirkpatrick <pgsql@rkirkpat.net>. |
| 8 | +# |
| 9 | +# If you find any problems with this script, or have suggestions |
| 10 | +# please send them to me. |
| 11 | + |
| 12 | +# Arguements for pg_ctl and then for the postmaster. Change as needed. |
| 13 | +ARGS="-w -D /home/postgres/data" |
| 14 | +PM_ARGS="-i -F" |
| 15 | + |
| 16 | +# Changes should not be needed beyond this point. |
4 | 17 |
|
| 18 | +# The path that is to be used for the script. |
5 | 19 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
| 20 | + |
| 21 | +# What to use to start up the postmster, and a few names. |
6 | 22 | DAEMON=/home/postgres/bin/pg_ctl
|
7 | 23 | NAME=postmaster
|
8 | 24 | FILE=postgresql
|
9 |
| -ARGS="-w -D /home/postgres/data -o -i -o -F" |
10 |
| -USER="postgres:postgres" |
11 |
| -LOG="/home/postgres/server.log" |
12 | 25 | DESC="PostgreSQL RDBMS"
|
13 | 26 |
|
14 |
| -test -f$DAEMON||exit 0 |
| 27 | +# Who to run pg_ctl as, should be postgres. |
| 28 | +USER="postgres:postgres" |
15 | 29 |
|
| 30 | +# Where to keep a log file. |
| 31 | +LOG="/usr/local/pgsql/server.log" |
| 32 | + |
| 33 | +# Only start if we can find pg_ctl. |
| 34 | +test -f$DAEMON||exit 0 |
16 | 35 | set -e
|
17 | 36 |
|
| 37 | +# Parse command line parameters. |
18 | 38 | case"$1"in
|
19 | 39 | start)
|
| 40 | +# Start the postmaster using pg_ctl and given options. |
20 | 41 | echo -n"Starting$DESC:"
|
21 |
| -su - postgres sh -c"$DAEMON start$ARGS >&$LOG" |
| 42 | +su - postgres sh -c"$DAEMON start$ARGS-o\"$PM_ARGS\">&$LOG" |
22 | 43 | echo"$NAME."
|
23 | 44 | ;;
|
24 | 45 | stop)
|
| 46 | +# Stop the postmaster using pg_ctl. |
25 | 47 | echo -n"Stopping$DESC:"
|
26 | 48 | su - postgres sh -c"$DAEMON stop >& /dev/null"
|
27 | 49 | echo"$NAME."
|
28 | 50 | ;;
|
29 | 51 | restart)
|
| 52 | +# Restart the postmaster by calling ourselves. |
30 | 53 | /etc/init.d/$FILE stop
|
31 | 54 | sleep 5
|
32 | 55 | /etc/init.d/$FILE start
|
33 | 56 | ;;
|
34 | 57 | status)
|
| 58 | +# Print the status of the postmaster. |
35 | 59 | su - postgres$DAEMON status
|
36 | 60 | ;;
|
37 | 61 | *)
|
| 62 | +# Print help. |
38 | 63 | N=/etc/init.d/$FILE
|
39 | 64 | echo"Usage:$N {start|stop|restart|status}">&2
|
40 | 65 | exit 1
|
|