This commit is contained in:
Heavybullets8 2022-08-12 10:07:33 -06:00
parent fc785b71b5
commit 6aa4458b14

View File

@ -27,10 +27,14 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-
mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}')
for pod in "${pod_id[@]}" for pod in "${pod_id[@]}"
do do
printf '%s\0' "${containers_temp[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then
containers_temp+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")"
continue
fi
printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue
containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")")
done done
containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz)
case "${#containers[@]}" in case "${#containers[@]}" in
0) 0)
echo -e "No containers available\nAre you sure the application in running?" echo -e "No containers available\nAre you sure the application in running?"