]> git.pld-linux.org Git - packages/postgresql.git/blobdiff - postgresql.init
- adapterized, remaining pl translations, BuildRequires: automake
[packages/postgresql.git] / postgresql.init
index 653181b44d50bb067f14b8e7e17ac5343b0e15c2..75f7b6f233faa94e2a41ced26aed2521586f9fa1 100644 (file)
@@ -32,6 +32,21 @@ if is_no "${NETWORKING}"; then
        exit 1
 fi
 
+# check if postmaster is realy alive
+if [ -f /var/lib/pgsql/postmaster.pid ]; then
+ if ps -p `head -1 /var/lib/pgsql/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 stoped. 
+       rm -f  /var/lock/subsys/postgresql
+fi
+
+
 # See how we were called.
 case "$1" in
   start)
@@ -56,7 +71,7 @@ case "$1" in
                        chown postgres.postgres $POSTGRES_DATA_DIR
                        chmod 700 $POSTGRES_DATA_DIR
                    fi
-                   su postgres -c "LD_LIBRARY_PATH=/usr/lib \
+                   TMPDIR=/tmp su postgres -c "LD_LIBRARY_PATH=/usr/lib \
                        initdb --pgdata=$POSTGRES_DATA_DIR \
                        -L /usr/share/postgresql"
                fi
@@ -64,9 +79,17 @@ case "$1" in
                msg_starting PostgreSQL 
                busy
                PGSQL_CMDLINE="$([ -n "$POSTGRES_DATA_DIR" ] && echo "-D $POSTGRES_DATA_DIR") \
-                   $([ "$POSTGRES_QUIET". = yes. ] && echo '-s -o -S') \
-                   $([ "$POSTGRES_DISABLE_FSYNC". = yes. ] && echo '-o -F')";
-               su postgres -c "/usr/bin/pg_ctl start $PGSQL_CMDLINE -l $POSTGRES_LOG 2>&1 >/dev/null"
+                   $([ "$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 start $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
@@ -78,6 +101,7 @@ case "$1" in
        touch /var/lock/subsys/postgresql
        ;;
   stop)
+
        if [ ! -f /var/lock/subsys/postgresql ]; then
                msg_Not_Running PostgreSQL
                exit 0  
@@ -85,7 +109,7 @@ case "$1" in
        msg_stopping postgreSQL
        busy
        PGSQL_CMDLINE="$([ -n "$POSTGRES_DATA_DIR" ] && echo "-D $POSTGRES_DATA_DIR")";
-       su postgres -c "/usr/bin/pg_ctl stop $PGSQL_CMDLINE -m fast 2>&1 >/dev/null"
+       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
@@ -99,19 +123,32 @@ case "$1" in
        ;;
   status)
        PGSQL_CMDLINE="$([ -n "$POSTGRES_DATA_DIR" ] && echo "-D $POSTGRES_DATA_DIR")";
-       su postgres -c "/usr/bin/pg_ctl status $PGSQL_CMDLINE"
+       TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl status $PGSQL_CMDLINE"
+       ;;
+  restart)
+       $0 stop
+       $0 start
        ;;
-  restart|reload)
+  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 -o -S') \
-               $([ "$POSTGRES_DISABLE_FSYNC". = yes. ] && echo '-o -F')";
-       su postgres -c "/usr/bin/pg_ctl restart $PGSQL_CMDLINE -m fast 2>&1 >/dev/null"
+           $([ "$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
This page took 0.040744 seconds and 4 git commands to generate.