]> git.pld-linux.org Git - packages/postgresql.git/blame - postgresql.init
- release++
[packages/postgresql.git] / postgresql.init
CommitLineData
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
b57548c1 21if [ -f /etc/sysconfig/postgresql ] ; then
22 . /etc/sysconfig/postgresql
03af0381 23else
b57548c1 24 ALLOW_TCP_CONNECTIONS=no
a869aa78 25 POSTGRES_DATA_DIR=/var/lib/psql
03af0381 26fi
27
c35cc882 28# Check that networking is up.
95633833
JR
29if is_no "${NETWORKING}"; then
30 msg_Network_Down Postgresql
d584f4fd 31 exit 1
32fi
d29ea5e3 33
d29ea5e3 34# See how we were called.
35case "$1" in
36 start)
c35cc882 37 # Check if the service is already running?
38 if [ ! -f /var/lock/subsys/postgresql ]; then
d4674174 39
40 # Sanity check
41 [ -f /tmp/.s.PGSQL.5432 ] || rm -f /tmp/.s.PGSQL.5432
42 STARTTEXT="Starting postgresql"
43
44 # Check for the PGDATA structure
45 if [ -f $POSTGRES_DATA_DIR/PG_VERSION ] && [ -d $POSTGRES_DATA_DIR/base/template1 ]; then
46 # Check version of existing PGDATA
47 if [ `cat $POSTGRES_DATA_DIR/PG_VERSION` != '6.5' ]; then
48 STARTTEXT="$STARTTEXT [Old version. Need to Upgrade]"
49 show "$STARTTEXT"; fail
50 exit 1
51 fi
52 else
53 # Create sample database
54 if [ ! -d $POSTGRES_DATA_DIR ]; then
55 mkdir -p $POSTGRES_DATA_DIR
56 chown postgres.postgres $POSTGRES_DATA_DIR
57 fi
95633833 58 show "Creating postgresql init database"
d4674174 59 busy
60 su postgres -c "LD_LIBRARY_PATH=/usr/lib \
61 initdb --pgdata=$POSTGRES_DATA_DIR \
62 --pglib=/usr/lib/pgsql &>/tmp/initdb.pgsql"
63 deltext; ok
64 fi
65
66 show "$STARTTEXT"
c35cc882 67 busy
9d56d95e 68 su postgres -c "/usr/bin/postmaster \
b57548c1 69 $([ "$ALLOW_TCP_CONNECTIONS" = yes ] && echo "-i") \
9d56d95e 70 $([ -n "$MAX_NUM_BACKENDS" ] && echo "-N $MAX_NUM_BACKENDS") \
d5443eaf 71 $([ -n "POSTGRES_$DATA_DIR" ] && echo "-D $POSTGRES_DATA_DIR") \
9d56d95e 72 -o \
73 $([ "$POSTGRES_QUIET" = yes ] && echo "-Q") \
dbdc14ef 74 $([ "$POSTGRES_DIABLE_FSYNC" = yes ] && echo "-F") 2> /dev/null &"
d5443eaf 75 sleep 2
70825085 76 if ps ax | grep -v grep | grep -q postmaster; then
d4674174 77 deltext; ok
70825085 78 else
d4674174 79 deltext; fail
70825085 80 fi
c35cc882 81 else
95633833 82 msg_Already_Running Postgresql
c35cc882 83 fi
d29ea5e3 84 touch /var/lock/subsys/postgresql
d29ea5e3 85 ;;
86 stop)
95633833 87 msg_stopping postgresql
d29ea5e3 88 killproc postmaster
89 sleep 2
90 rm -f /var/run/postmaster.pid
91 rm -f /var/lock/subsys/postgresql
92 ;;
93 status)
94 status postmaster
95 ;;
c35cc882 96 restart|reload)
d29ea5e3 97 $0 stop
98 $0 start
99 ;;
100 *)
95633833 101 msg_Usage "$0 {start|stop|status|restart|reload}"
d29ea5e3 102 exit 1
103esac
104
105exit 0
This page took 0.075868 seconds and 4 git commands to generate.