#! /bin/sh

IP_ADDRESS=$(ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)

# Ensure correct ownership and permissions on volumes
chown riak:riak /var/lib/riak /var/log/riak
chmod 755 /var/lib/riak /var/log/riak

# Open file descriptor limit
ulimit -n 4096

# Ensure the Erlang node name is set correctly
sed -i.bak "s/riak@127.0.0.1/riak@${IP_ADDRESS}/" /etc/riak/riak.conf

# Ensure the desired Riak backend is set correctly
sed -i.bak "s/storage_backend = \(.*\)}/storage_backend = ${DOCKER_RIAK_BACKEND}}/" /etc/riak/riak.conf

# Start Riak
exec /sbin/setuser riak "$(ls -d /usr/lib/riak/erts*)/bin/run_erl" "/tmp/riak" \
   "/var/log/riak" "exec /usr/sbin/riak console"

#! /bin/sh

IP_ADDRESS=$(ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)

# Ensure correct ownership and permissions on volumes
chown riak:riak /var/lib/riak /var/log/riak
chmod 755 /var/lib/riak /var/log/riak

# Open file descriptor limit
ulimit -n 4096

# Ensure the Erlang node name is set correctly
sed -i.bak "s/riak@127.0.0.1/riak@${IP_ADDRESS}/" /etc/riak/riak.conf

# Ensure the desired Riak backend is set correctly
sed -i.bak "s/storage_backend = \(.*\)/storage_backend = ${DOCKER_RIAK_BACKEND}/" /etc/riak/riak.conf

# Start Riak
exec /sbin/setuser riak "$(ls -d /usr/lib/riak/erts*)/bin/run_erl" "/tmp/riak" \
   "/var/log/riak" "exec /usr/sbin/riak console"

Fix invalid regular expression in setting storage backend
Fix invalid regular expression in setting storage backend

The previous regular expression had curly braces, which were left over
from the Erlang `app.config` file. `riak.conf` is sysctl based, not
Erlang based. This changeset updates the regular expression so that it
matches properly.
