Prechádzať zdrojové kódy

Add the 'debug' option on the entrypoint script

By giving the 'debug' argument to the entrypoint you
can list what value you will send to the influxdb database

Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
Jeremy MAURO 4 rokov pred
rodič
commit
9996cccfbf
1 zmenil súbory, kde vykonal 14 pridanie a 8 odobranie
  1. 14 8
      scripts/docker-entrypoint.sh

+ 14 - 8
scripts/docker-entrypoint.sh

@@ -18,12 +18,18 @@ download_bandwidth=$(echo "${json_result}" | jq -r '.download.bandwidth')
 upload_bandwidth=$(echo "${json_result}" | jq -r '.upload.bandwidth')
 packet_loss=$(echo "${json_result}" | jq -r '.packetLoss')
 
-# Ensure InfluxDB database exists
-curl \
-    -d "q=CREATE DATABASE ${influxdb_db}" \
-    "${influxdb_url}/query"
-
 # Write metric to InfluxDB
-curl \
-    -d "speedtest,result_id=${result_id} ping_latency=${ping_latency},download_bandwidth=${download_bandwidth},upload_bandwidth=${upload_bandwidth},packet_loss=${packet_loss}" \
-    "${influxdb_url}/write?db=${influxdb_db}"
+INFLUXDB_APPEND="speedtest,result_id=${result_id} ping_latency=${ping_latency},download_bandwidth=${download_bandwidth},upload_bandwidth=${upload_bandwidth},packet_loss=${packet_loss}"
+
+if [ "$1" == "debug" ]; then
+	echo "[DEBUG] INFLUXDB: ${INFLUXDB_APPEND}"
+else
+	# Ensure InfluxDB database exists
+	curl \
+	    -d "q=CREATE DATABASE ${influxdb_db}" \
+	    "${influxdb_url}/query"
+
+	curl \
+	    -d "${INFLUXDB_APPEND}" \
+	    "${influxdb_url}/write?db=${influxdb_db}"
+fi