#!/bin/bash function quit { exit } PREFIX="/opt/dbcore" DBCORE_USER=`whoami` ABSPATH="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")" DIRPATH=`dirname "$ABSPATH"` while [ $# -gt 0 ] do case $1 in -p) PREFIX=$2 shift 2 ;; -t) TEMPLATE=$2 shift 2 ;; -d) DATA=$2 shift 2 ;; -v) VIEW=$2 shift 2 ;; -u) DBCORE_USER=$2 shift 2 ;; *) echo "usage: $0 [-p {prefix} -t {template} -d {data_dir} -v {view_dir} -u {user}]" quit ;; esac done if test ! -n "$DATA"; then DATA="$PREFIX/var/lib"; fi if test ! -n "$VIEW"; then VIEW="$PREFIX/var/lib"; fi echo "==> configuring dbcore in rel/overlay.config" cat > rel/overlay.config << EOF {prefix, "$PREFIX"}. {data_dir, "$DATA"}. {view_dir, "$VIEW"}. {user, "$DBCORE_USER"}. {node_name, "-name dbcore"}. {cluster_port, 5984}. {backend_port, 5986}. EOF cat > install.mk << EOF # The contents of this file are auto-generated by configure prefix = $PREFIX data_dir = $DATA view_dir = $VIEW user = $DBCORE_USER EOF # finally, a few config files for local development nodes for i in 1 2 3; do cat > rel/dev$i.config << EOF {prefix, "$DIRPATH/rel/dev$i"}. {data_dir, "$DIRPATH/rel/tmpdata/dev$i"}. {view_dir, "$DIRPATH/rel/tmpdata/dev$i"}. {node_name, "-name dev$i@127.0.0.1"}. {cluster_port, `expr 10000 \* $i + 5984`}. {backend_port, `expr 10000 \* $i + 5986`}. EOF done cat rel/overlay.config