2014-11-15 04:39:34 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-07-24 01:46:06 +00:00
|
|
|
if [ -f /conf/env ]; then
|
|
|
|
. /conf/env
|
|
|
|
fi
|
|
|
|
|
2014-11-15 04:39:34 +00:00
|
|
|
if [ ! -e /conf/elasticsearch.* ]; then
|
|
|
|
cp $ES_HOME/config/elasticsearch.yml /conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -e /conf/logging.* ]; then
|
|
|
|
cp $ES_HOME/config/logging.yml /conf
|
|
|
|
fi
|
|
|
|
|
2015-10-30 00:58:28 +00:00
|
|
|
OPTS="$OPTS -Des.path.conf=/conf \
|
2014-11-15 18:05:01 +00:00
|
|
|
-Des.path.data=/data \
|
|
|
|
-Des.path.logs=/data \
|
|
|
|
-Des.transport.tcp.port=9300 \
|
2016-07-10 14:00:10 +00:00
|
|
|
-Des.http.port=9200"
|
2014-11-15 04:39:34 +00:00
|
|
|
|
2016-09-04 21:10:08 +00:00
|
|
|
discoverIpFromLink() {
|
|
|
|
dev=$1
|
|
|
|
mode=$2
|
|
|
|
ip=`ipaddr show dev $dev scope global|awk '$1 == "inet" { if (!match($2,"/32")) { gsub("/.*","",$2) ; print $2 } }'`
|
|
|
|
echo "Discovered $mode address $ip for $dev"
|
|
|
|
OPTS="$OPTS -Des.$mode.host=$ip"
|
|
|
|
}
|
|
|
|
|
2016-09-04 20:25:04 +00:00
|
|
|
if [ "$DISCOVER_TRANSPORT_IP" != "" ]; then
|
2016-09-04 21:10:08 +00:00
|
|
|
discoverIpFromLink $DISCOVER_TRANSPORT_IP transport
|
|
|
|
fi
|
|
|
|
if [ "$DISCOVER_HTTP_IP" != "" ]; then
|
|
|
|
discoverIpFromLink $DISCOVER_HTTP_IP http
|
2016-09-04 20:25:04 +00:00
|
|
|
fi
|
|
|
|
|
2014-11-15 04:39:34 +00:00
|
|
|
if [ -n "$CLUSTER" ]; then
|
|
|
|
OPTS="$OPTS -Des.cluster.name=$CLUSTER"
|
2015-07-24 16:49:57 +00:00
|
|
|
if [ -n "$CLUSTER_FROM" ]; then
|
|
|
|
if [ -d /data/$CLUSTER_FROM -a ! -d /data/$CLUSTER ]; then
|
|
|
|
echo "Performing cluster data migration from $CLUSTER_FROM to $CLUSTER"
|
|
|
|
mv /data/$CLUSTER_FROM /data/$CLUSTER
|
|
|
|
fi
|
|
|
|
fi
|
2014-11-15 04:39:34 +00:00
|
|
|
fi
|
2014-11-15 20:10:06 +00:00
|
|
|
|
2014-11-15 04:39:34 +00:00
|
|
|
if [ -n "$NODE_NAME" ]; then
|
|
|
|
OPTS="$OPTS -Des.node.name=$NODE_NAME"
|
|
|
|
fi
|
2014-11-15 20:10:06 +00:00
|
|
|
|
2015-11-28 17:35:59 +00:00
|
|
|
if [ -n "$MULTICAST" ]; then
|
|
|
|
OPTS="$OPTS -Des.discovery.zen.ping.multicast.enabled=$MULTICAST"
|
|
|
|
fi
|
|
|
|
|
2014-11-15 04:39:34 +00:00
|
|
|
if [ -n "$UNICAST_HOSTS" ]; then
|
|
|
|
OPTS="$OPTS -Des.discovery.zen.ping.unicast.hosts=$UNICAST_HOSTS"
|
|
|
|
fi
|
2014-11-15 20:10:06 +00:00
|
|
|
|
2014-11-15 18:05:01 +00:00
|
|
|
if [ -n "$PUBLISH_AS" ]; then
|
|
|
|
OPTS="$OPTS -Des.transport.publish_host=$(echo $PUBLISH_AS | awk -F: '{print $1}')"
|
|
|
|
OPTS="$OPTS -Des.transport.publish_port=$(echo $PUBLISH_AS | awk -F: '{if ($2) print $2; else print 9300}')"
|
|
|
|
fi
|
2014-11-15 04:39:34 +00:00
|
|
|
|
2016-07-10 21:32:55 +00:00
|
|
|
if [ -n "$TYPE" ]; then
|
|
|
|
case $TYPE in
|
|
|
|
MASTER)
|
|
|
|
OPTS="$OPTS --node.master=true --node.data=false"
|
|
|
|
;;
|
|
|
|
|
|
|
|
GATEWAY)
|
|
|
|
OPTS="$OPTS --node.master=false --node.data=false"
|
|
|
|
;;
|
|
|
|
|
|
|
|
DATA|NON_MASTER)
|
|
|
|
OPTS="$OPTS --node.master=false --node.data=true"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Unknown node type. Please use MASTER|GATEWAY|DATA|NON_MASTER"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$MIN_MASTERS" ]; then
|
|
|
|
OPTS="$OPTS --discovery.zen.minimum_master_nodes=$MIN_MASTERS"
|
|
|
|
fi
|
|
|
|
|
2016-07-31 15:03:43 +00:00
|
|
|
mkdir -p /conf/plugins
|
2016-07-10 14:00:10 +00:00
|
|
|
OPTS="$OPTS --path.plugins=/conf/plugins"
|
|
|
|
|
2014-11-15 20:10:06 +00:00
|
|
|
if [ -n "$PLUGINS" ]; then
|
2016-07-31 15:03:43 +00:00
|
|
|
PLUGIN_OPTS="-Des.path.conf=/conf -Des.path.plugins=/conf/plugins"
|
2014-11-15 20:10:06 +00:00
|
|
|
for p in $(echo $PLUGINS | awk -v RS=, '{print}')
|
|
|
|
do
|
2014-11-15 21:12:49 +00:00
|
|
|
echo "Installing the plugin $p"
|
2016-07-31 15:03:43 +00:00
|
|
|
$ES_HOME/bin/plugin $PLUGIN_OPTS install $p -t 1m -b
|
2014-11-15 20:10:06 +00:00
|
|
|
done
|
2016-07-09 17:52:02 +00:00
|
|
|
else
|
|
|
|
mkdir -p /conf/plugins
|
2014-11-15 20:10:06 +00:00
|
|
|
fi
|
|
|
|
|
2016-07-09 17:52:02 +00:00
|
|
|
mkdir -p /conf/scripts
|
|
|
|
|
2014-11-15 21:12:49 +00:00
|
|
|
echo "Starting Elasticsearch with the options $OPTS"
|
2016-07-09 17:52:02 +00:00
|
|
|
CMD="$ES_HOME/bin/elasticsearch $OPTS"
|
|
|
|
if [ `id -u` = 0 ]; then
|
|
|
|
echo "Running as non-root..."
|
|
|
|
chown -R $DEFAULT_ES_USER /data
|
|
|
|
set -x
|
2016-07-10 14:00:10 +00:00
|
|
|
su -c "$CMD" $DEFAULT_ES_USER
|
2016-07-09 17:52:02 +00:00
|
|
|
else
|
|
|
|
$CMD
|
|
|
|
fi
|