#!/bin/sh # This script adds wterl to a riak github repo. Run it in the riak repo # directory. # # First it adds wterl, then runs "make all devrel" and then enables the # wterl storage backend in the resulting dev nodes. # # This script is intended to be temporary. Once wterl 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/rebar.config if ! grep -q wterl $file ; then echo echo "Modifying $file, saving the original as ${file}.orig ..." perl -i.orig -pe '/\bsext\b/ && print qq( {wterl, ".*", {git, "git\@github.com:basho/wterl.git", "master"}},\n)' $file fi file=./deps/riak_kv/src/riak_kv.app.src if ! grep -q wterl $file ; then echo echo "Modifying $file, saving the original as ${file}.orig ..." perl -i.orig -pe '/\briak_pipe\b/ && print " wterl,\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_wterl_backend/; print } elsif (/\{eleveldb,/) { $eleveldb++; print } elsif ($eleveldb && /^\s+\]\},/) { $eleveldb = 0; print; print qq(\n {wterl, [\n {data_root, "./data/wt"}\n ]},\n\n) } else { print }' dev/dev*/etc/app.config exit 0