#!/bin/sh set -e NAME="sfive-es" IMG="docker.elastic.co/elasticsearch/elasticsearch" PERSIST_D="/srv/build/sfive/es" create() { mkdir -p "$PERSIST_D/data" "$PERSIST_D/logs" "$PERSIST_D/config" sudo docker run --detach --rm -p 127.0.0.1:9200:9200 --name "$NAME" -e ES_JAVA_OPTS="-Xms1g -Xmx1g" -v "$PERSIST_D/data:/usr/share/elasticsearch/data" -v "$PERSIST_D/logs:/usr/share/elasticsearch/logs" -v "$PERSIST_D/config:/usr/share/elasticsearch/config" "$IMG:$1" } stop() { sudo docker stop "$NAME" } logs() { sudo docker logs "$NAME" $@ } case "$1" in create) if [ -z "$2" ]; then echo "Please specify a version" exit 1 fi create "$2" ;; stop) stop ;; upgrade) if [ -z "$2" ]; then echo "Please specify a version" exit 1 fi tag="$2" sudo docker pull "$IMG:$tag" stop create "$tag" ;; logs) shift logs $@ ;; *) echo "Usage $0 (create|stop|upgrade|logs)" exit 1 ;; esac exit 0