Skip to content

Commit

Permalink
Create install-loki-docker-log-driver.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
geleeroyale authored Oct 9, 2023
1 parent befa791 commit 0657707
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions install-loki-docker-log-driver.sh
Original file line number Diff line number Diff line change
@@ -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!"

0 comments on commit 0657707

Please sign in to comment.