]> git.pld-linux.org Git - packages/postgresql.git/commitdiff
- merged from multi-db-clusters
authorwrobell <wrobell@pld-linux.org>
Thu, 28 Nov 2002 11:37:50 +0000 (11:37 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    postgresql.init -> 1.42
    postgresql.sysconfig -> 1.15

postgresql.init
postgresql.sysconfig

index 765a47945adba8c56d3ed2d69b80702856e74d91..4606a6bb534f0bf17991b8c07a71c6be4c8c494c 100644 (file)
@@ -6,10 +6,9 @@
 # chkconfig:   345 84 25
 #
 # description: Starts and stops the PostgreSQL backend daemon that handles \
-#              all database requests.
+#                              all database requests.
 #
 # processname: postmaster
-# pidfile:     $POSTGRES_DATA_DIR/postmaster.pid
 
 # Source function library
 . /etc/rc.d/init.d/functions
 # Get network config
 . /etc/sysconfig/network
 
-# Service config defaults
-ALLOW_TCP_CONNECTIONS=no
-ALLOW_USE_SSL=no
-POSTGRES_DATA_DIR=/var/lib/pgsql
-POSTGRES_LOG=/var/log/pgsql
-ENCODING=UNICODE
-LOCALE=${LANG:-C}
-
 # Get service config
 if [ -f /etc/sysconfig/postgresql ] ; then
-        . /etc/sysconfig/postgresql
+       . /etc/sysconfig/postgresql
+else
+       echo "Error: /etc/sysconfig/postgresql not found"
+       echo " PostgreSQL can't be run."
+       exit 1
 fi
 
 # Check that networking is up.
@@ -36,177 +31,117 @@ if is_no "${NETWORKING}"; then
        exit 1
 fi
 
-# check if postmaster is realy alive
-if [ -f $POSTGRES_DATA_DIR/postmaster.pid ]; then
-    if ps -p `head -1 $POSTGRES_DATA_DIR/postmaster.pid` > /dev/null ; then
-       # ok. it's alive
-       echo > /dev/null;
-    else
-       # oh, it has crashed
-       rm -f  /var/lock/subsys/postgresql
-    fi
-else
-       # it's stopped.
-       rm -f  /var/lock/subsys/postgresql
-fi
+pgstatus () {
+       PG_STATUS="unknown"
+       PG_PID="unknown"
+       status=`/usr/bin/pg_ctl -D $1 status`
 
+       if echo "$status" | grep -q 'pg_ctl: postmaster or postgres is not running'; then
+               PG_STATUS="not running"
+       elif echo "$status" | grep -q 'pg_ctl: postmaster is running'; then
+               PG_STATUS="running"
+               PG_PID=`echo "$status" | sed 's/^pg_ctl:.*pid: \([0-9]\+\).*/\1/' | head -1`
+       fi
+}
+
+action="$1"
+
+# any db cluster as command line argument?
+if [ $# -gt 1 ]; then
+       shift
+       POSTGRES_DB_CLUSTERS="$@"
+fi
 
 # See how we were called.
-case "$1" in
-  start)
-       # Check if the service is already running?
-       if [ -f /var/lock/subsys/postgresql ]; then
-               msg_already_running PostgreSQL
-       else    
-               if is_yes "$ALLOW_USE_SSL"; then
-                       if is_no "$ALLOW_TCP_CONNECTIONS"; then
-                               nls "You must enable ALLOW_TCP_CONNECTIONS in order to use SSL"
-                               exit 1
-                       elif [ ! -f "$POSTGRES_DATA_DIR/server.key" ]; then
-                               nls "$POSTGRES_DATA_DIR/server.key not found!"
-                               exit 1
-                       elif [ ! -f "$POSTGRES_DATA_DIR/server.crt" ]; then
-                               nls "$POSTGRES_DATA_DIR/server.crt not found!"
-                               exit 1
+case "$action" in
+       start)
+               for pgdir in $POSTGRES_DB_CLUSTERS; do
+                       pgstatus "$pgdir"
+                       if [ "$PG_STATUS" = "running" ]; then
+                               if ps ax | grep -v grep | grep -q "$PG_PID"; then
+                                       msg_already_running "PostgreSQL $pgdir"
+                               else
+                                       msg_not_running "PostgreSQL $pgdir"
+                                       rm -f $pgdir/postmaster.pid
+                                       $0 start "$pgdir"
+                               fi
+                       else
+                               msg_starting "PostgreSQL $pgdir"
+                               busy
+                               TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl -w -D $pgdir start 2>&1 >/dev/null"
+                               
+                               pgstatus "$pgdir"
+                               if [ "$PG_STATUS" != "unknown" -a "$PG_PID" != "unknown" ]; then
+                                       deltext; ok
+                               else
+                                       deltext; fail 
+                               fi
                        fi
-               fi
-               
-               # Sanity check
-               [ -e /tmp/.s.PGSQL.5432 ] || rm -f /tmp/.s.PGSQL.5432
-               [ -f /tmp/.s.PGSQL.5432.lock ] || rm -f /tmp/.s.PGSQL.5432.lock
-               
-               # Check for the PGDATA structure
-               if [ -f $POSTGRES_DATA_DIR/PG_VERSION ] && [ -f $POSTGRES_DATA_DIR/global/pg_control ]; then
-                   # Check version of existing PGDATA
-                   if [ `cat $POSTGRES_DATA_DIR/PG_VERSION` != '7.2' ]; then
-                       show "Databases created under incompatibile version. Migrate them first."; fail
-                       exit 1
-                   fi
-               else
-                   echo "Postgresql database not initialized. Try \"$0 init\" before start."
-                   exit 1
-               fi
-               
-               msg_starting PostgreSQL 
-               busy
-               PGSQL_CMDLINE="$([ -n "$POSTGRES_DATA_DIR" ] && echo "-D $POSTGRES_DATA_DIR") \
-                   $(is_yes "$POSTGRES_QUIET" && echo '-s')";
-               POSTMASTER_OPTIONS=" \
-                   $(is_yes "$POSTGRES_QUIET" && echo '-S') \
-                   $(is_yes "$POSTGRES_DISABLE_FSYNC" && echo '-F') \
-                   $(is_yes "$ALLOW_TCP_CONNECTIONS" && echo '-i') \
-                   $(is_yes "$ALLOW_USE_SSL" && echo '-l') \
-                   $([ "$BUFFERS" ] && echo \-B $BUFFERS) \
-                   $([ "$MAXCONN" ] && echo \-N $MAXCONN)";
-
-               TMPDIR=/tmp su postgres -c "\
-                       $(echo "/usr/bin/pg_ctl start -w $PGSQL_CMDLINE -l $POSTGRES_LOG") \
-                       $([ "$POSTMASTER_OPTIONS". != . ] && echo "-o '$POSTMASTER_OPTIONS'") \
-                       $(echo "2>&1 >/dev/null")";
-               
-               out=`status postmaster`
-               if [ $? -eq 0 ]; then 
-                   deltext; ok
-               else
-                   deltext; fail 
-                   exit 1      
-               fi
-       fi
-       touch /var/lock/subsys/postgresql
+               done
        ;;
-  stop)
-
-       if [ ! -f /var/lock/subsys/postgresql ]; then
-               msg_not_running PostgreSQL
-               exit 0  
-       fi
-       msg_stopping PostgreSQL
-       busy
-       PGSQL_CMDLINE="$([ -n "$POSTGRES_DATA_DIR" ] && echo "-D $POSTGRES_DATA_DIR")";
-       TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl stop $PGSQL_CMDLINE -m fast 2>&1 >/dev/null"
-       out=`status postmaster`
-       if [ $? -eq 0 ]; then
-               deltext; fail
-               echo -e "\n$out";
-               exit 1
-       else
-               deltext; ok
-       fi
-       rm -f $POSTGRES_DATA_DIR/postmaster.pid
-       rm -f /var/lock/subsys/postgresql
+       stop)
+               for pgdir in $POSTGRES_DB_CLUSTERS; do
+                       pgstatus "$pgdir"
+                       if [ "$PG_STATUS" = "not running" ]; then
+                               msg_not_running "PostgreSQL $pgdir"
+                       else
+                               msg_stopping "PostgreSQL $pgdir"
+                               busy
+
+                               if ps ax | grep -v grep | grep -q "$PG_PID"; then
+                                       TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl -w -D $pgdir stop -m fast 2>&1 >/dev/null"
+                                       pgstatus "$pgdir"
+                                       if [ "$PG_STATUS" != "not running" ]; then
+                                               deltext; fail
+                                       else
+                                               deltext; ok
+                                       fi
+                               else
+                                       deltext; died
+                               fi
+
+                               rm -f $pgdir/postmaster.pid
+                       fi
+               done
        ;;
-  status)
-       PGSQL_CMDLINE="$([ -n "$POSTGRES_DATA_DIR" ] && echo "-D $POSTGRES_DATA_DIR")";
-       TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl status $PGSQL_CMDLINE"
+       status)
+               for pgdir in $POSTGRES_DB_CLUSTERS; do
+                       TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl -D $pgdir status"
+               done
        ;;
-  restart)
-       $0 stop
-       $0 start
+       restart)
+               $0 stop "$POSTGRES_DB_CLUSTERS"
+               $0 start "$POSTGRES_DB_CLUSTERS"
        ;;
-  reload)
-       if [ ! -f /var/lock/subsys/postgresql ]; then
-               msg_not_running PostgreSQL
-               exit 0  
-       fi
-       msg_reloading PostgreSQL
-       busy
-
-       PGSQL_CMDLINE="$([ -n "$POSTGRES_DATA_DIR" ] && echo "-D $POSTGRES_DATA_DIR") \
-           $([ "$POSTGRES_QUIET". = yes. ] && echo '-s')";
-       POSTMASTER_OPTIONS=" \
-           $([ "$POSTGRES_QUIET". = yes. ] && echo '-S') \
-           $([ "$POSTGRES_DISABLE_FSYNC". = yes. ] && echo '-F') \
-           $([ "$ALLOW_TCP_CONNECTIONS". = yes. ] && echo '-i')";
-
-       TMPDIR=/tmp su postgres -c "\
-               $(echo "/usr/bin/pg_ctl restart $PGSQL_CMDLINE -l $POSTGRES_LOG") \
-               $([ "$POSTMASTER_OPTIONS". != . ] && echo "-o '$POSTMASTER_OPTIONS'") \
-               $(echo "2>&1 >/dev/null")";
-
-       out=`status postmaster`
-       if [ $? -eq 0 ]; then
-               deltext; ok
-       else
-               deltext; fail
-               echo -e "\n$out";
-               exit 1
-       fi
-       ;;
-    init)
-       if [ -f "$POSTGRES_DATA_DIR/PG_VERSION" ]; then
-           echo "Seems that database is initialized now. Remove by hand $POSTGRES_DATA_DIR"
-           echo "before initialize database."
-           exit 1
-       fi
-
-       echo -n "Specify encoding for pgsql database (eg: LATIN2, KOI8) [$ENCODING]: "
-       read new_encoding
-       ENCODING=${new_encoding:-$ENCODING}
-       echo -n "Specify locale for pgsql database (eg: pl_PL, de_DE) [$LOCALE]: "
-       read new_locale
-       LOCALE=${new_locale:-$LOCALE}
-
-       show "Creating initial postgresql database using $ENCODING/$LOCALE encoding/locale"
-       started
-
-        # Create sample database
-       if [ ! -d $POSTGRES_DATA_DIR ]; then
-           mkdir -p $POSTGRES_DATA_DIR
-           chown postgres.postgres $POSTGRES_DATA_DIR
-           chmod 700 $POSTGRES_DATA_DIR
-       fi
-
-       
-       LC_ALL=$LOCALE; export LC_ALL
-       TMPDIR=/tmp su - postgres -s /bin/sh -c "LD_LIBRARY_PATH=/usr/lib \
-                       initdb --pgdata=$POSTGRES_DATA_DIR \
-                       -L /usr/share/postgresql -E $ENCODING"
-
-       echo "REMEMBER to setup password for user \"postgres\"!"
+       reload)
+               for pgdir in $POSTGRES_DB_CLUSTERS; do
+                       pgstatus "$pgdir"
+                       if [ "$PG_STATUS" = "not running" ]; then
+                               msg_not_running "PostgreSQL $pgdir"
+                       else
+                               msg_reloading "PostgreSQL $pgdir"
+                               busy
+
+                               if ps ax | grep -v grep | grep -q "$PG_PID"; then
+                                       TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl -D $pgdir restart 2>&1 >/dev/null"
+
+                                       pgstatus "$pgdir"
+                                       if [ "$PG_STATUS" = "running" ]; then
+                                               deltext; ok
+                                       else
+                                               deltext; fail
+                                       fi
+                               else
+                                       deltext; died
+                                       rm -f $pgdir/postmaster.pid
+                                       $0 start
+                               fi
+                       fi
+               done
        ;;
-  *)
-       msg_usage "$0 {start|stop|status|restart|reload}"
-       exit 1
+       *)
+               msg_usage "$0 {start|stop|status|restart|reload}"
+               exit 1
 esac
 
 exit 0
index b006111331efa7bc6ab87ebdfe1903b4ecd7bfcc..d8060085304a2a38f41a4395ff8ac5f1671b73e8 100644 (file)
@@ -1,57 +1,10 @@
 # $Revision$
 
-# Root of the tree of database directories
-POSTGRES_DATA_DIR=/var/lib/pgsql
+# standard setting
+# POSTGRES_DB_CLUSTERS="/var/lib/pgsql"
 
-#
-# postgres(1) backend options run by postmaster
-#
-# run postgres(1) backend in quiet mode
-POSTGRES_QUIET=no
+# predictable usage
+# POSTGRES_DB_CLUSTERS="/var/lib/pgsql/01 /var/lib/pgsql/02"
 
-# Enable listening on TCP port. Without this postmaster responds
-# only on unix socket
-ALLOW_TCP_CONNECTIONS=no
-
-# For production machines you should increase those numbers to avoid "Too 
-# many connections" messages. Buffers should be (at least) MaxConn*2.
-# But: watch carefully that you won't exceed system resources!!
-# Leave it blank to have default (safe) 32 clients/64 buffers.
-
-MAXCONN=
-BUFFERS=
-
-# Allow using SSL on TCP connections. Requires ALLOW_TCP_CONNECTIONS to be
-# set to yes. Also, you must supply key and certificate files
-# ($POSTGRES_DATA_DIR/server.{key,crt})
-ALLOW_USE_SSL=no
-
-# Disable automatic fsync() call after each transaction. This option
-# improves performance, but an operating system crash while a transaction is
-# in progress will probably cause data loss.
-POSTGRES_DISABLE_FSYNC=no
-
-# Where postmaster output is redirected
-POSTGRES_LOG=/var/log/pgsql
-
-# Default database chcaracter encoding
-# Avaible character sets:
-#
-# Encoding     | Description
-# --------------------------------------------------------------
-# SQL_ASCII    | ASCII
-# EUC_JP       | Japanese EUC
-# EUC_CN       | Chinese EUC
-# EUC_KR       | Korean EUC
-# EUC_TW       | Taiwan EUC
-# UNICODE      | Unicode(UTF-8)
-# MULE_INTERNAL | Mule internal
-# LATIN1       | ISO 8859-1 English and some European languages
-# LATIN2       | ISO 8859-2 English and some European languages
-# LATIN3       | ISO 8859-3 English and some European languages
-# LATIN4       | ISO 8859-4 English and some European languages
-# LATIN5       | ISO 8859-5 English and some European languages
-# KOI8         | KOI8-R
-# WIN          | Windows CP1251
-# ALT          | Windows CP866                 
-ENCODING=UNICODE
\ No newline at end of file
+# new database disk arrived
+# POSTGRES_DB_CLUSTERS="/var/lib/pgsql/01 /var/lib/pgsql/02 /mnt/db/01"
This page took 0.091209 seconds and 4 git commands to generate.