]> git.pld-linux.org Git - packages/postgresql.git/blob - postgresql.init
- fixed loading postgresql.sysconfig
[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/postgresql ] ; then
22         . /etc/sysconfig/postgresql
23 else
24         ALLOW_TCP_CONNECTIONS=no
25         POSTGRES_DATA_DIR=/var/state/psql
26 fi
27
28 # Check that networking is up.
29 if [ "${NETWORKING}" = "no" ]; then
30         echo "WARNING: Networking is down. Postgresql service can't be runed."
31         exit 1
32 fi
33
34 # Sanity check
35 [ -f /tmp/.s.PGSQL.5432 ] || rm -f /tmp/.s.PGSQL.5432
36
37 # See how we were called.
38 case "$1" in
39   start)
40         # Check if the service is already running?
41         if [ ! -f /var/lock/subsys/postgresql ]; then
42                 show Starting postgresql
43                 busy
44                 su postgres -c "/usr/bin/postmaster \
45                         $([ "$ALLOW_TCP_CONNECTIONS" = yes ] && echo "-i") \
46                         $([ -n "$MAX_NUM_BACKENDS" ] && echo "-N $MAX_NUM_BACKENDS") \
47                         $([ -n "$POSTGRES_DATA_DIR" ] && echo "-D $POSTGRES_DATA_DIR") \
48                         -o \
49                         $([ "$POSTGRES_QUIET" = yes ] && echo "-Q") \
50                         $([ "$POSTGRES_DIABLE_FSYNC" = yes ] && echo "-F") \
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.076533 seconds and 4 git commands to generate.