-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcf_java_check_docker.sh
More file actions
59 lines (55 loc) · 1.78 KB
/
cf_java_check_docker.sh
File metadata and controls
59 lines (55 loc) · 1.78 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
SPACES=($(cf spaces | awk '{print $1}' | tail -n +4))
echo "Choose a space:"
echo "0) All spaces"
for i in "${!SPACES[@]}"; do
echo "$((i+1))) ${SPACES[$i]}"
done
read -p "Enter space number: " SPACE_NUMBER
if [ $SPACE_NUMBER -eq 0 ]; then
for space in "${SPACES[@]}"; do
echo "Space: $space"
cf target -s $space
APPS=($(cf apps | awk '{print $1}' | tail -n +5))
for app in "${APPS[@]}"; do
echo " App: $app"
DOCKER_CONTAINERS=$(cf curl /v3/apps/$(cf app $app --guid)/relationships/containers | jq -r '.data[].guid')
if [[ -z "$DOCKER_CONTAINERS" ]]; then
echo " No Docker containers found for this app."
else
for container in $DOCKER_CONTAINERS; do
echo " Container ID: $container"
env=$(docker inspect $container | grep JAVA_HOME)
if [[ -z "$env" ]]; then
echo " Java is not defined in the environment of this container."
else
echo "$env"
fi
done
fi
done
done
else
SPACE_INDEX=$((SPACE_NUMBER-1))
SPACE=${SPACES[$SPACE_INDEX]}
echo "Space: $SPACE"
cf target -s $SPACE
APPS=($(cf apps | awk '{print $1}' | tail -n +5))
for app in "${APPS[@]}"; do
echo " App: $app"
DOCKER_CONTAINERS=$(cf curl /v3/apps/$(cf app $app --guid)/relationships/containers | jq -r '.data[].guid')
if [[ -z "$DOCKER_CONTAINERS" ]]; then
echo " No Docker containers found for this app."
else
for container in $DOCKER_CONTAINERS; do
echo " Container ID: $container"
env=$(docker inspect $container | grep JAVA_HOME)
if [[ -z "$env" ]]; then
echo " Java is not defined in the environment of this container."
else
echo "$env"
fi
done
fi
done
fi