-
Notifications
You must be signed in to change notification settings - Fork 4
/
run_influxdb
executable file
·29 lines (22 loc) · 935 Bytes
/
run_influxdb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/ash
CONFIG_FILE="/etc/influxdb/config.toml"
#Dynamically change the value of 'max-open-shards' to what 'ulimit -n' returns
sed -i "s/^max-open-shards.*/max-open-shards = $(ulimit -n)/g" ${CONFIG_FILE}
#Configure InfluxDB Cluster
if [ -n "${HOSTNAME}" ]; then
if [ "${HOSTNAME}" == "auto" ]; then
#set hostname with IPv4 eth0
HOSTIPNAME=$(ip a show dev eth0 | grep inet | grep eth0 | sed -e 's/^.*inet.//g' -e 's/\/.*$//g')
sed -i "s/^# hostname.*$/hostname = \"${HOSTIPNAME}\"/g" ${CONFIG_FILE}
else
sed -i "s/^# hostname.*$/hostname = \"${HOSTNAME}\"/g" ${CONFIG_FILE}
fi
fi
if [ -n "${SEED}" ]; then
sed -i "s/^# seed-servers.*$/seed-servers = [\"${SEED}\"]/g" ${CONFIG_FILE}
fi
if [ -n "${REPLICATION_FACTOR}" ]; then
sed -i "s/replication-factor = 1/replication-factor = ${REPLICATION_FACTOR}/g" ${CONFIG_FILE}
fi
echo "=> Starting InfluxDB ..."
exec /usr/bin/influxdb -config=/etc/influxdb/config.toml