Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 154 lines (136 sloc) 3.29 KB
#!/bin/sh
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
OS=`uname -s`
ARCH=`uname -m`
VERSION=`git describe --tags`
# PREFIX is by default the current directory
PREFIX="/opt/refuge"
REFUGE_USER=`whoami`
ABSPATH="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"
if test ! -n "$DIRPATH"; then DIRPATH=`dirname "$ABSPATH"`; fi
basename=`basename $0`
display_error () {
if test -n "$1"; then
echo $1 >&2
fi
echo >&2
echo "Try \`"$basename" -h' for more information." >&2
false
}
display_help ()
{
cat << EOF
Usage: $basename [OPTION]
-p PREFIX prefix path
-d DATA set the database directory ($PREFIX/var/lib)
-l LOG set the log directory ($PREFIX/var/log)
-v VIEW set the view directory ($PREFIX/var/lib)
-u USER set the user directory
-r RUN set the run directory ($PREFIX/var/run)
-s SYSCONF sett the sysconf directory ($PREFIX/etc)
EOF
}
CURL_BIN=`which curl`
if ! test -n "CURL_BIN"; then
display_error "Error: curl is required. Add it to 'PATH'"
exit 1
fi
while [ $# -gt 0 ]
do
case $1
in
-p)
PREFIX=$2
shift 2
;;
-d)
DATA=$2
shift 2
;;
-l)
LOG=$2
shift 2
;;
-v)
VIEW=$2
shift 2
;;
-u)
REFUGE_USER=$2
shift 2
;;
-r)
RUN=$2
shift 2
;;
-R)
REFUGE_USER=refuge
shift 1
;;
-s)
SYSCONF=$2
shift 2
;;
*)
display_help
exit
;;
esac
done
if test ! -n "$DATA"; then DATA="$PREFIX/var/lib"; fi
if test ! -n "$VIEW"; then VIEW="$PREFIX/var/lib"; fi
if test ! -n "$SYSCONF"; then SYSCONF="$PREFIX/etc"; fi
if test ! -n "$RUN"; then RUN="$PREFIX/var/run"; fi
if test ! -n "$LOG"; then LOG="$PREFIX/var/log"; fi
echo "==> configuring refuge in rel/refuge.config"
cat > rel/refuge.config << EOF
{prefix, "$PREFIX"}.
{data_dir, "$DATA"}.
{view_dir, "$VIEW"}.
{sysconf_dir, "$SYSCONF"}.
{run_dir, "$RUN"}.
{log_dir, "$LOG"}.
{user, "$REFUGE_USER"}.
{node_name, "-sname refuge"}.
{couchdb_port, 5984}.
{ssl_port, 6986}.
EOF
cat > config.mk << EOF
# The contents of this file are auto-generated by configure
PREFIX = $PREFIX
DATADIR = $DATA
VIEWDIR = $VIEW
SYSCONF_DIR = $SYSCONF
RUNDIR = $RUN
LOGDIR = $LOG
REFUGE_USER = $REFUGE_USER
OS = $OS
ARCH = $ARCH
VERSION = $VERSION
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"}.
{sysconf_dir, "$DIRPATH/rel/dev$i/etc"}.
{run_dir, "$DIRPATH/rel/dev$i/var/run"}.
{log_dir, "$DIRPATH/rel/dev$i/var/log"}.
{user, "$REFUGE_USER"}.
{node_name, "-name dev$i@127.0.0.1"}.
{couchdb_port, `expr 10000 \* $i + 5984`}.
{ssl_port, `expr 10000 \* $i + 5986`}.
EOF
done
cat rel/refuge.config