summaryrefslogtreecommitdiff
path: root/postgresql/bin
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-10-12 11:47:03 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-10-12 11:47:03 +0200
commit7b91c886d9db1f81818e3b73b37fcb5d85734f59 (patch)
treea6fc8b6c4f9d9e848fa8c92cc25c4468713d4df9 /postgresql/bin
downloadapp.sh-misc-7b91c886d9db1f81818e3b73b37fcb5d85734f59.tar.gz
app.sh-misc-7b91c886d9db1f81818e3b73b37fcb5d85734f59.tar.bz2
app.sh-misc-7b91c886d9db1f81818e3b73b37fcb5d85734f59.tar.xz
app.sh-misc-7b91c886d9db1f81818e3b73b37fcb5d85734f59.zip
o Initial import of postgresql setup for app.sh.
Diffstat (limited to 'postgresql/bin')
-rw-r--r--postgresql/bin/archive-command6
-rw-r--r--postgresql/bin/postgres-wrapper62
2 files changed, 68 insertions, 0 deletions
diff --git a/postgresql/bin/archive-command b/postgresql/bin/archive-command
new file mode 100644
index 0000000..fa5f2c0
--- /dev/null
+++ b/postgresql/bin/archive-command
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+set -e
+echo `date` "Copying $1 to ../wal/$2" >> /tmp/archive-command.txt
+mkdir -p ../wal
+exec cp "$1" "../wal/$2"
diff --git a/postgresql/bin/postgres-wrapper b/postgresql/bin/postgres-wrapper
new file mode 100644
index 0000000..26b69c3
--- /dev/null
+++ b/postgresql/bin/postgres-wrapper
@@ -0,0 +1,62 @@
+#!/bin/bash -e
+
+PATH=$PATH:/opt/local/bin
+CONF=etc/postgresql.conf
+
+if [ -z "$DATA" ]
+then
+ DATA=../../../data
+fi
+
+if [ ! -d $DATA ]
+then
+ echo "Missing data dir: $DATA"
+ exit 1
+fi
+
+if [ -z "$LOG" ]
+then
+ LOG=../../../log
+fi
+
+if [ ! -d $LOG ]
+then
+ echo "Missing log dir: $LOG, creating"
+ mkdir -p $LOG
+fi
+
+LOG=$LOG/postgresql.log
+
+if [ ! -r $CONF ]
+then
+ echo "Missing config file: $CONF"
+ exit 1
+fi
+
+# TODO: figure out how if pg_ctl exits with sane exit codes.
+
+x=`dirname $CONF`
+CONF=`cd $x; pwd`/`basename $CONF`
+DATA=`cd $DATA; pwd`
+x=`dirname $LOG`
+LOG=`cd $x; pwd`/`basename $LOG`
+
+case "$APPSH_METHOD" in
+ start)
+ echo "Starting postgresql"
+ exec pg_ctl start \
+ -D "$DATA" \
+ -o "-c config_file=$CONF" \
+ -l $LOG &
+ ;;
+ stop)
+ echo "Stopping postgresql"
+ exec pg_ctl stop \
+ -D "$DATA" \
+ -o "-c config_file=$CONF"
+ ;;
+ *)
+ echo "Unknown method: $APPSH_METHOD"
+ exit 0
+ ;;
+esac