summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--postgresql/Makefile14
-rw-r--r--postgresql/bin/archive-command6
-rw-r--r--postgresql/bin/postgres-wrapper62
-rw-r--r--postgresql/etc/app.conf1
-rw-r--r--postgresql/etc/postgresql.conf24
6 files changed, 109 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c1d64ce
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+zip
+*.zip
diff --git a/postgresql/Makefile b/postgresql/Makefile
new file mode 100644
index 0000000..7279f36
--- /dev/null
+++ b/postgresql/Makefile
@@ -0,0 +1,14 @@
+VERSION=1.0-SNAPSHOT
+ZIP_FILE=postgresql-$(VERSION).zip
+
+all: $(ZIP_FILE)
+
+clean:
+ rm -f $(ZIP_FILE)
+
+postgresql-$(VERSION).zip:
+ rm -rf zip
+ mkdir -p zip/root
+ cp -r etc zip/root/etc/
+ cp -r bin zip/root/bin/
+ (cd zip; zip -r ../$@ *)
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
diff --git a/postgresql/etc/app.conf b/postgresql/etc/app.conf
new file mode 100644
index 0000000..b66592b
--- /dev/null
+++ b/postgresql/etc/app.conf
@@ -0,0 +1 @@
+app.method=bin/postgres-wrapper
diff --git a/postgresql/etc/postgresql.conf b/postgresql/etc/postgresql.conf
new file mode 100644
index 0000000..fcde2ed
--- /dev/null
+++ b/postgresql/etc/postgresql.conf
@@ -0,0 +1,24 @@
+max_connections = 20
+shared_buffers = 1600kB
+datestyle = 'iso, mdy'
+lc_messages = 'en_US.UTF-8'
+lc_monetary = 'en_US.UTF-8'
+lc_numeric = 'en_US.UTF-8'
+lc_time = 'en_US.UTF-8'
+default_text_search_config = 'pg_catalog.english'
+
+# Logging
+log_destination='csvlog,stderr'
+logging_collector=true
+log_directory='../log'
+log_filename='postmaster-%Y-%m-%d.log'
+log_min_messages=INFO
+log_min_error_statement=INFO
+log_min_duration_statement=10
+log_connections=true
+
+# WAL
+wal_level=archive
+
+archive_mode=true
+archive_command='../current/bin/archive-command "%p" "%f"'