2020-04-06 12:00:13 +00:00
|
|
|
#!/usr/local/bin/bash
|
|
|
|
# This script installs the current release of InfluxDB
|
|
|
|
|
|
|
|
#####
|
|
|
|
#
|
|
|
|
# Init and Mounts
|
|
|
|
#
|
|
|
|
#####
|
|
|
|
|
2020-03-13 23:06:09 +00:00
|
|
|
# Initialise variables
|
2020-04-06 12:00:13 +00:00
|
|
|
JAIL_NAME="influxdb"
|
2020-04-26 12:55:22 +00:00
|
|
|
# shellcheck disable=SC2154
|
|
|
|
JAIL_IP="${influxdb_ip4_addr%/*}"
|
2020-04-06 12:00:13 +00:00
|
|
|
INCLUDES_PATH="${SCRIPT_DIR}/jails/influxdb/includes"
|
2020-04-26 12:55:22 +00:00
|
|
|
# shellcheck disable=SC2154
|
|
|
|
DATABASE="${influxdb_database}"
|
2020-04-06 12:00:13 +00:00
|
|
|
|
2020-03-13 23:06:09 +00:00
|
|
|
# Mount and configure proper configuration location
|
2020-04-26 12:55:22 +00:00
|
|
|
# shellcheck disable=SC2154
|
2020-03-13 23:06:09 +00:00
|
|
|
cp -rf "${INCLUDES_PATH}/influxd.conf" "/mnt/${global_dataset_config}/${JAIL_NAME}/influxd.conf"
|
|
|
|
iocage exec "${JAIL_NAME}" mkdir -p /config/db/data /config/db/meta /config/db/wal
|
|
|
|
iocage exec "${JAIL_NAME}" chown -R influxd:influxd /config/db
|
|
|
|
iocage exec "${JAIL_NAME}" sysrc influxd_conf="/config/influxd.conf"
|
2020-04-06 12:00:13 +00:00
|
|
|
iocage exec "${JAIL_NAME}" sysrc influxd_enable="YES"
|
|
|
|
|
|
|
|
# Start influxdb and wait for it to startup
|
|
|
|
iocage exec "${JAIL_NAME}" service influxd start
|
|
|
|
sleep 15
|
|
|
|
|
|
|
|
# Create database and restart
|
2020-03-13 23:06:09 +00:00
|
|
|
if iocage exec "${JAIL_NAME}" curl -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE ${DATABASE}"; then
|
|
|
|
echo "Database created."
|
|
|
|
else
|
|
|
|
echo "Database creation failed. Please attempt to create the database manually."
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-06 12:00:13 +00:00
|
|
|
|
|
|
|
# Done!
|
|
|
|
echo "Installation complete!"
|
2020-03-13 23:06:09 +00:00
|
|
|
echo "Your may connect InfluxDB plugins to the InfluxDB jail at http://${JAIL_IP}:8086."
|
2020-04-06 12:00:13 +00:00
|
|
|
echo "You may connect InfluxDB plugins to the InfluxDB jail at http://${JAIL_IP}:8086."
|
|
|
|
echo ""
|
|
|
|
echo "Database Information"
|
|
|
|
echo "--------------------"
|
|
|
|
echo "Database = ${DATABASE} at http://${JAIL_IP}:8086."
|
|
|
|
echo ""
|