#!/bin/sh # This script adds hanoidb to a riak github repo. Run it in the riak repo # directory. # # First it adds hanoidb, then runs "make all devrel" and then enables the # hanoidb storage backend in the resulting dev nodes. # # This script is intended to be temporary. Once hanoidb is made into a proper # riak citizen, this script will no longer be needed. set -e wd=`pwd` if [ `basename $wd` != riak ]; then echo "This doesn't appear to be a riak repo directory. Exiting." exit 1 fi if [ -d dev ]; then echo echo 'NOTE: THIS SCRIPT WILL DELETE YOUR EXISTING DEV DIRECTORY!' while [ 1 ]; do printf '\n%s' ' Do you wish to proceed? [no] ' read answer answer=${answer:-n} case $answer in [Nn]*) exit 0 ;; [Yy]*) break ;; *) echo 'Please answer y or n.' ;; esac done fi ./rebar get-deps file=./deps/riak_kv/src/riak_kv.app.src if ! grep -q hanoidb $file ; then echo echo "Modifying $file, saving the original as ${file}.orig ..." perl -i.orig -pe '/\bos_mon,/ && print qq( hanoidb,\n)' $file fi file=./deps/riak_kv/rebar.config if ! grep -q hanoidb $file ; then echo echo "Modifying $file, saving the original as ${file}.orig ..." perl -i.orig -pe '/\bsext\b/ && print qq( {hanoidb, ".*", {git, "git\@github.com:basho/hanoidb.git", "master"}},\n)' $file fi ./rebar get-deps rm -rf dev make all devrel echo echo 'Modifying all dev/dev*/etc/app.config files, saving originals with .orig suffix...' perl -i.orig -ne 'if (/\bstorage_backend,/) { s/(storage_backend, )[^\}]+/\1riak_kv_hanoidb_backend/; print } elsif (/\{eleveldb,/) { $eleveldb++; print } elsif ($eleveldb && /^\s+\]\},/) { $eleveldb = 0; print; print qq(\n {hanoidb, [\n {data_root, "./data/hanoidb"}\n ]},\n\n) } else { print }' dev/dev*/etc/app.config exit 0