do not add duplicate containers

This commit is contained in:
Heavybullets8 2022-08-12 09:13:37 -06:00
parent 7f6018b5d5
commit a03598b1b7

View File

@ -27,6 +27,7 @@ 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[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}')" && continue
containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')")
done done
case "${#containers[@]}" in case "${#containers[@]}" in