From 5079b57f942d6038c99223f5004e6a02676a6ded Mon Sep 17 00:00:00 2001
From: t3chn0m4g3 <t3chn0m4g3@gmail.com>
Date: Tue, 15 Oct 2019 15:41:21 +0000
Subject: [PATCH] add option to unlock ES for r/w

---
 bin/unlock_es.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100755 bin/unlock_es.sh

diff --git a/bin/unlock_es.sh b/bin/unlock_es.sh
new file mode 100755
index 00000000..606d85eb
--- /dev/null
+++ b/bin/unlock_es.sh
@@ -0,0 +1,19 @@
+#/bin/bash
+# Unlock all ES indices for read / write mode
+# Useful in cases where ES locked all indices after disk quota has been reached
+# Make sure ES is available
+myES="http://127.0.0.1:64298/"
+myESSTATUS=$(curl -s -XGET ''$myES'_cluster/health' | jq '.' | grep -c "green\|yellow")
+if ! [ "$myESSTATUS" = "1" ]
+  then
+    echo "### Elasticsearch is not available, try starting via 'systemctl start tpot'."
+    exit
+  else
+    echo "### Elasticsearch is available, now continuing."
+    echo
+fi
+
+echo "### Trying to unlock all ES indices for read / write operation: "
+curl -XPUT -H "Content-Type: application/json" ''$myES'_all/_settings' -d '{"index.blocks.read_only_allow_delete": null}'
+echo
+