forked from open-edge-platform/edge-ai-suites
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_dashboard.sh
More file actions
executable file
·40 lines (35 loc) · 1.28 KB
/
update_dashboard.sh
File metadata and controls
executable file
·40 lines (35 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Get HOST_IP from command line argument or .env file
if [ $# -ge 1 ]; then
HOST_IP="$1"
echo "Using HOST_IP from command line: $HOST_IP"
else
echo "Error: No command line argument provided!"
exit 1
fi
# Check for required variables
if [ -z "$HOST_IP" ]; then
echo "Error: HOST_IP environment variable is not set."
exit 1
fi
#############################################
# Update dashboard JSON files IP address #
#############################################
# Prefer the new folder, then legacy grafana folder
if [ -d "./src/grafana/dashboards" ]; then
DASH_DIR="./src/grafana/dashboards"
echo "Found dashboards folder: $DASH_DIR"
elif [ -d "./src/grafana/dashboards" ]; then
DASH_DIR="./src/grafana/dashboards"
echo "Using legacy grafana dashboards folder: $DASH_DIR"
else
echo "Warning: No dashboards folder found."
DASH_DIR=""
fi
if [ -n "$DASH_DIR" ]; then
for file in "$DASH_DIR"/*.json; do
[ -f "$file" ] && sed -i "s|\"text\": *\"https://[0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}/|\"text\": \"https://$HOST_IP/|g" "$file"
sed -i "s|\"value\": *\"https://[0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}/|\"value\": \"https://$HOST_IP/|g" "$file"
sed -i "s|\"query\": *\"https://[0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}/|\"query\": \"https://$HOST_IP/|g" "$file"
done
fi