From 0657707af4aaeb23283ecfbcedd69865ad114237 Mon Sep 17 00:00:00 2001 From: geleeroyale Date: Mon, 9 Oct 2023 14:27:48 +0200 Subject: [PATCH] Create install-loki-docker-log-driver.sh --- install-loki-docker-log-driver.sh | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 install-loki-docker-log-driver.sh diff --git a/install-loki-docker-log-driver.sh b/install-loki-docker-log-driver.sh new file mode 100644 index 0000000..6688e74 --- /dev/null +++ b/install-loki-docker-log-driver.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Step 1: Check if Loki Docker Driver is already installed +if docker plugin ls | grep -q "loki"; then + echo "Driver Client already running" + exit 1 +fi + +# Step 3: Install the Loki Docker Driver +docker plugin install grafana/loki-docker-driver:2.9.1 --alias loki --grant-all-permissions + +# Step 4: Check if /etc/docker/daemon.json exists and has the required content +REQUIRED_CONTENT='{ + "debug": true, + "log-driver": "loki" +}' + +if [[ -e /etc/docker/daemon.json ]]; then + CURRENT_CONTENT=$(cat /etc/docker/daemon.json) + if [[ "$CURRENT_CONTENT" == "$REQUIRED_CONTENT" ]]; then + echo "Loki Docker Log driver already enabled" + exit 1 + else + echo "Error: /etc/docker/daemon.json exists but content is not as expected." + exit 1 + fi +else + # Step 5: If the file does not exist, create it with the content + echo "$REQUIRED_CONTENT" > /etc/docker/daemon.json +fi + +echo "Loki Docker Driver Client installed and configured successfully!"