]> git.pld-linux.org Git - packages/postgresql.git/blob - postgresql.init
- added support for /etc/sysconfig/postgresql
[packages/postgresql.git] / postgresql.init
1 #!/bin/sh
2 #
3 # postgresql    This is the init script for starting up the PostgreSQL
4 #               server
5 #
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
14 # Source function library
15 . /etc/rc.d/init.d/functions
16
17 # Get network config
18 . /etc/sysconfig/network
19
20 # Get service config
21 if [ -f /etc/sysconfig/syslog ] ; then
22         . /etc/sysconfig/syslog
23 else
24         ALLOW_TCP=no
25 fi
26
27 if [ "$ALLOW_TCP" = yes ]; then
28         ALLOW_TCP="-i"
29 else
30         ALLOW_TCP=""
31 fi
32
33
34 # Check that networking is up.
35 if [ "${NETWORKING}" = "no" ]; then
36         echo "WARNING: Networking is down. Postgresql service can't be runed."
37         exit 1
38 fi
39
40 # Sanity check
41 [ -f /tmp/.s.PGSQL.5432 ] || rm -f /tmp/.s.PGSQL.5432
42
43 # See how we were called.
44 case "$1" in
45   start)
46         # Check if the service is already running?
47         if [ ! -f /var/lock/subsys/postgresql ]; then
48                 show Starting postgresql
49                 busy
50                 su postgres -c "/usr/bin/postmaster $ALLOW_TCP $OPTIONS -D /var/state/pgsql" &
51                 
52                 if ps ax | grep -v grep | grep -q postmaster; then
53                     deltext;ok
54                 else
55                     deltext;fail
56                 fi
57         else
58                 echo "Postgresql already is running"
59         fi
60         touch /var/lock/subsys/postgresql
61         ;;
62   stop)
63         show Stopping postgresql service
64         killproc postmaster
65         sleep 2
66         rm -f /var/run/postmaster.pid
67         rm -f /var/lock/subsys/postgresql
68         ;;
69   status)
70         status postmaster
71         ;;
72   restart|reload)
73         $0 stop
74         $0 start
75         ;;
76   *)
77         echo "Usage: postgresql {start|stop|status|restart|reload}"
78         exit 1
79 esac
80
81 exit 0
This page took 0.618275 seconds and 4 git commands to generate.