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)
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
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
touch /var/lock/subsys/postgresql
;;
stop)
+
if [ ! -f /var/lock/subsys/postgresql ]; then
msg_Not_Running PostgreSQL
exit 0
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
;;
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