]>
Commit | Line | Data |
---|---|---|
c35cc882 | 1 | #!/bin/sh |
2 | # | |
d29ea5e3 | 3 | # postgresql This is the init script for starting up the PostgreSQL |
4 | # server | |
5 | # | |
c35cc882 | 6 | # chkconfig: 345 85 15 |
7 | # | |
8 | # description: Starts and stops the PostgreSQL backend daemon that handles \ | |
9 | # all database requests. | |
10 | # | |
11 | # processname: postmaster | |
12 | # pidfile: /var/run/postmaster.pid | |
13 | ||
c35cc882 | 14 | # Source function library |
d29ea5e3 | 15 | . /etc/rc.d/init.d/functions |
16 | ||
c35cc882 | 17 | # Get network config |
d29ea5e3 | 18 | . /etc/sysconfig/network |
19 | ||
c35cc882 | 20 | # Get service config |
21 | [ -f /etc/sysconfig/postgresql ] && . /etc/sysconfig/postgresql | |
d29ea5e3 | 22 | |
c35cc882 | 23 | # Check that networking is up. |
d584f4fd | 24 | if [ "${NETWORKING}" = "no" ]; then |
25 | echo "WARNING: Networking is down. Postgresql service can't be runed." | |
26 | exit 1 | |
27 | fi | |
d29ea5e3 | 28 | |
c35cc882 | 29 | # Sanity check |
d29ea5e3 | 30 | [ -f /tmp/.s.PGSQL.5432 ] || rm -f /tmp/.s.PGSQL.5432 |
31 | ||
d29ea5e3 | 32 | # See how we were called. |
33 | case "$1" in | |
34 | start) | |
c35cc882 | 35 | # Check if the service is already running? |
36 | if [ ! -f /var/lock/subsys/postgresql ]; then | |
37 | show Starting postgresql | |
38 | busy | |
70825085 | 39 | su postgres -c "/usr/bin/postmaster -D /var/state/pgsql" |
40 | ||
41 | if ps ax | grep -v grep | grep -q postmaster; then | |
42 | deltext;ok | |
43 | else | |
44 | deltext;fail | |
45 | fi | |
c35cc882 | 46 | else |
47 | echo "Postgresql already is running" | |
48 | fi | |
d29ea5e3 | 49 | touch /var/lock/subsys/postgresql |
d29ea5e3 | 50 | ;; |
51 | stop) | |
52 | show Stopping postgresql service | |
53 | killproc postmaster | |
54 | sleep 2 | |
55 | rm -f /var/run/postmaster.pid | |
56 | rm -f /var/lock/subsys/postgresql | |
57 | ;; | |
58 | status) | |
59 | status postmaster | |
60 | ;; | |
c35cc882 | 61 | restart|reload) |
d29ea5e3 | 62 | $0 stop |
63 | $0 start | |
64 | ;; | |
65 | *) | |
c35cc882 | 66 | echo "Usage: postgresql {start|stop|status|restart|reload}" |
d29ea5e3 | 67 | exit 1 |
68 | esac | |
69 | ||
70 | exit 0 |