summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile36
-rw-r--r--README.md39
-rwxr-xr-xconfigure18
4 files changed, 82 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..aee2e4c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+config.mk
diff --git a/Makefile b/Makefile
index 331966a..b28ae64 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,31 @@
-MAN= temp-postgres.1
-BINDIR= /usr/local/bin
-MANDIR= /usr/local/man/man
+# Portable makefile supporting OpenBSD and GNU/Linux.
-beforeinstall:
- ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${.CURDIR}/temp-postgres.sh ${DESTDIR}${BINDIR}/temp-postgres
+PREFIX = /usr/local
+INSTALL = install
+BINDIR = bin
+BINOWN = root
+BINGRP = root
+BINMODE = 555
+MANDIR = man/man
+MANOWN = root
+MANGRP = root
+MANMODE = 444
-.include <bsd.prog.mk>
+include config.mk
+
+all:
+
+clean:
+
+lint:
+ shellcheck -a temp-postgres.sh
+ mandoc -T lint -W warning temp-postgres.1
+ -mandoc -T lint -W all temp-postgres.1
+
+install:
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} temp-postgres.sh ${DESTDIR}${PREFIX}/${BINDIR}/temp-postgres
+ ${INSTALL} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} temp-postgres.1 ${DESTDIR}${PREFIX}/${MANDIR}1/temp-postgres.1
+
+uninstall:
+ rm -f ${DESTDIR}${PREFIX}/${BINDIR}/temp-postgres
+ rm -f ${DESTDIR}${PREFIX}/${MANDIR}1/temp-postgres.1
diff --git a/README.md b/README.md
index b2a4747..1463056 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,37 @@
-# temp-postgres
+# Temp PostgreSQL
-The temp-postgres utility runs the PostgreSQL server off a temporary data directory.
-See [this](https://www.skreutz.com/posts/temporary-postgresql-server/) blog post for an introduction, and refer to the man page for details.
+The `temp-postgres` utility runs the PostgreSQL server off a temporary data
+directory. See [this][intro] blog post for an introduction.
-## Install
+[intro]: https://www.skreutz.com/posts/temporary-postgresql-server/
+
+## Usage
+
+Create a temporary database "test" with superuser "alex":
+
+ $ temp-postgres test alex
+
+Connect to the "test" database:
+
+ $ psql --host=localhost test alex
+
+See the manual page for details.
+
+## Dependencies
+
+The `temp-postgres` utility depends on `sh(1)` and `postgres(1)`.
+
+On OpenBSD you can install the dependencies using `pkg_add(1)`:
+
+ $ doas pkg_add postgresql-server postgresql-client
+
+On Void Linux you can install the dependencies using `xbps-install(1)`:
+
+ $ sudo xbps-install -S dash postgresql postgresql-client
+
+## Installation
+
+ $ ./configure
+ $ make
+ $ sudo make install
-Run `make install` as root to install the `temp-postgres` utility and man page.
diff --git a/configure b/configure
new file mode 100755
index 0000000..9a1e936
--- /dev/null
+++ b/configure
@@ -0,0 +1,18 @@
+#! /bin/sh
+
+set -o errexit
+set -o nounset
+
+exec 3>config.mk
+
+case "$( uname )" in
+ OpenBSD)
+ echo 'BINGRP = bin' 1>&3
+ echo 'MANGRP = bin' 1>&3
+ ;;
+ Linux)
+ echo 'BINMODE = 755' 1>&3
+ echo 'MANMODE = 644' 1>&3
+ echo 'MANDIR = share/man/man' 1>&3
+ ;;
+esac
Generated by cgit. See skreutz.com for my tech blog and contact information.