Skip to content

Instantly share code, notes, and snippets.

@salekseev
Created December 8, 2016 18:55
Show Gist options
  • Save salekseev/e427a489e536eb9fe2e76bd2df688a32 to your computer and use it in GitHub Desktop.
Save salekseev/e427a489e536eb9fe2e76bd2df688a32 to your computer and use it in GitHub Desktop.
Script to start KOPF Elasticsearch app on OS X via Docker
#!/bin/bash
# elasticsearch url
elasticsearch_hosts="devesdatasa100.athenahealth.com:9251,devesdatasa101.athenahealth.com:9251,devesdatasa102.athenahealth.com:9251"
port=$(( ((RANDOM<<15)|RANDOM) % 63001 + 2000 ))
function usage()
{
echo "Script to start KOPF Elasticsearch app"
echo ""
echo "$0"
echo -e "\t-h --help"
echo -e "\t--elasticsearch-hosts=$elasticsearch_hosts"
echo ""
}
while [ "$1" != "" ]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
case $PARAM in
-h | --help)
usage
exit
;;
--elasticsearch-hosts)
elasticsearch_hosts=$VALUE
;;
*)
echo "ERROR: unknown parameter \"$PARAM\""
usage
exit 1
;;
esac
shift
done
# ensure tools are availabel
command -v docker >/dev/null 2>&1 || \
{
echo "I require docker but it's not installed. Aborting." 1>&2
exit 1
}
$(sleep 2 && open http://localhost:$port) &
docker run --rm -it -p $port:80 -e KOPF_ES_SERVERS=${elasticsearch_hosts} -e KOPF_SERVER_NAME=localhost lmenezes/elasticsearch-kopf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment