-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create install-loki-docker-log-driver.sh
- Loading branch information
1 parent
befa791
commit 0657707
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" |