Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
blob: eed31687fae015834a8de69778ff6eb09657df96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /bin/sh
#
# PostgreSQL	Start, stop, and get status on the PostgreSQL RDMBS.	
#               This script is Linux distribution independent 
#                 (or at least should be :).
# 
# By Ryan Kirkpatrick <pgsql@rkirkpat.net>.
#
# If you find any problems with this script, or have suggestions
# please send them to me.

# Arguements for pg_ctl and then for the postmaster. Change as needed.
ARGS="-w -D /home/postgres/data"
PM_ARGS="-i -F"

# Changes should not be needed beyond this point.

# The path that is to be used for the script.
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# What to use to start up the postmster, and a few names.
DAEMON=/usr/local/pgsql/bin/pg_ctl
NAME=postmaster
FILE=postgresql
DESC="PostgreSQL RDBMS"

# Who to run pg_ctl as, should be postgres.
USER="postgres:postgres"

# Where to keep a log file.
LOG="/usr/local/pgsql/server.log"

# Only start if we can find pg_ctl.
test -f $DAEMON || exit 0
set -e

# Parse command line parameters.
case "$1" in
  start)
	# Start the postmaster using pg_ctl and given options.
	echo -n "Starting $DESC: "
	su - postgres sh -c "$DAEMON start $ARGS -o \"$PM_ARGS\" $LOG 2>&1"
	echo "$NAME."
	;;
  stop)
	# Stop the postmaster using pg_ctl.
	echo -n "Stopping $DESC: "
	su - postgres sh -c "$DAEMON stop > /dev/null 2>&1"
	echo "$NAME."
	;;
  restart)
	# Restart the postmaster by calling ourselves.
	/etc/init.d/$FILE stop
	sleep 5
	/etc/init.d/$FILE start
	;;
  status)
	# Print the status of the postmaster.
	su - postgres $DAEMON status
	;;
  *)
	# Print help.
	N=/etc/init.d/$FILE
	echo "Usage: $N {start|stop|restart|status}" 1>&2
	exit 1
	;;
esac

exit 0