]> granicus.if.org Git - postgresql/blob - contrib/start-scripts/linux
Patch to add comments to Linux startup script.
[postgresql] / contrib / start-scripts / linux
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 # $Header: /cvsroot/pgsql/contrib/start-scripts/linux,v 1.3 2001/07/30 14:52:42 momjian Exp $
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 pg_ctl as, should be "postgres".
38 PGUSER=postgres
39
40 # Where to keep a log file
41 PGLOG="$PGDATA/serverlog"
42
43 ## STOP EDITING HERE
44
45 # Check for echo -n vs echo \c
46 if echo '\c' | grep -s c >/dev/null 2>&1 ; then
47     ECHO_N="echo -n"
48     ECHO_C=""
49 else
50     ECHO_N="echo"
51     ECHO_C='\c'
52 fi
53
54 # The path that is to be used for the script
55 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
56
57 # What to use to start up the postmaster
58 DAEMON="$prefix/bin/pg_ctl"
59
60 set -e
61
62 # Only start if we can find pg_ctl.
63 test -f $DAEMON || exit 0
64
65 # Parse command line parameters.
66 case $1 in
67   start)
68         $ECHO_N "Starting PostgreSQL: "$ECHO_C
69         su - $PGUSER -c "$DAEMON start -D '$PGDATA' -s -l $PGLOG" 
70         echo "ok"
71         ;;
72   stop)
73         echo -n "Stopping PostgreSQL: "
74         su - $PGUSER -c "$DAEMON stop -D '$PGDATA' -s -m fast"
75         echo "ok"
76         ;;
77   restart)
78         echo -n "Restarting PostgreSQL: "
79         su - $PGUSER -c "$DAEMON restart -D '$PGDATA' -s -m fast"
80         echo "ok"
81         ;;
82   status)
83         su - $PGUSER -c "$DAEMON status -D '$PGDATA'"
84         ;;
85   *)
86         # Print help
87         echo "Usage: $0 {start|stop|restart|status}" 1>&2
88         exit 1
89         ;;
90 esac
91
92 exit 0