Update dotfiles/.local/motd.sh

This commit is contained in:
Brian Zalewski 2022-10-28 19:37:01 +00:00
parent a11873b099
commit 10a5d89f12

View file

@ -399,47 +399,49 @@ print_services() {
}
print_podman() {
printf "\\n"
printf " \\033[1;37mPodman:\\033[0m\\n"
if type jq > /dev/null; then
printf "\\n"
printf " \\033[1;37mPodman:\\033[0m\\n"
podman_version=$(sudo podman version --format json | jq -r '.Client.Version')
podman_space=$(generate_space "$podman_version" 23)
podman_images=$(sudo podman images --format json | jq '. | length')
podman_version=$(sudo podman version --format json | jq -r '.Client.Version')
podman_space=$(generate_space "$podman_version" 23)
podman_images=$(sudo podman images --format json | jq '. | length')
printf " %s Version %s%s%s %s Images\\n\\n" "$PODMAN_VERSION_ICON" "$podman_version" "$podman_space" "$PODMAN_IMAGES_ICON" "$podman_images"
printf " %s Version %s%s%s %s Images\\n\\n" "$PODMAN_VERSION_ICON" "$podman_version" "$podman_space" "$PODMAN_IMAGES_ICON" "$podman_images"
podman_list=$(sudo podman pod ls --sort name --format json)
podman_pods=$(echo "$podman_list" | jq -r '.[] .Name')
podman_list=$(sudo podman pod ls --sort name --format json)
podman_pods=$(echo "$podman_list" | jq -r '.[] .Name')
echo "$podman_pods" | while read -r pod; do
if [ "$(echo "$podman_list" | jq -r ".[] | select(.Name == \"$pod\") | .Status")" = "Running" ]; then
pod_space=$(generate_space "$pod" 34)
echo "$podman_pods" | while read -r pod; do
if [ "$(echo "$podman_list" | jq -r ".[] | select(.Name == \"$pod\") | .Status")" = "Running" ]; then
pod_space=$(generate_space "$pod" 34)
pod_container_running="$(echo "$podman_list" | jq -r ".[] | select(.Name == \"$pod\") | .Containers[] | select(.Status == \"running\") | .Status" | wc -l)"
pod_container_running="$(echo "$podman_list" | jq -r ".[] | select(.Name == \"$pod\") | .Containers[] | select(.Status == \"running\") | .Status" | wc -l)"
if [ "$pod_container_running" -ne 0 ]; then
pod_container_running=$(printf "\\033[%um%u Running\\033[0m" "$PODMAN_RUNNING_COLOR" "$pod_container_running")
fi
if [ "$pod_container_running" -ne 0 ]; then
pod_container_running=$(printf "\\033[%um%u Running\\033[0m" "$PODMAN_RUNNING_COLOR" "$pod_container_running")
fi
pod_container_other="$(echo "$podman_list" | jq -r ".[] | select(.Name == \"$pod\") | .Containers[] | select(.Status != \"running\") | .Status" | wc -l)"
pod_container_other="$(echo "$podman_list" | jq -r ".[] | select(.Name == \"$pod\") | .Containers[] | select(.Status != \"running\") | .Status" | wc -l)"
if [ "$pod_container_other" -ne 0 ]; then
pod_container_other=$(printf ", \\033[%um%u Other\\033[0m" "$PODMAN_OTHER_COLOR" "$pod_container_other")
if [ "$pod_container_other" -ne 0 ]; then
pod_container_other=$(printf ", \\033[%um%u Other\\033[0m" "$PODMAN_OTHER_COLOR" "$pod_container_other")
else
pod_container_other=""
fi
pod_status="$pod_container_running$pod_container_other"
printf " \\033[%um%s\\033[0m %s%s%s\\n" "$PODMAN_RUNNING_COLOR" "$PODMAN_RUNNING_ICON" "$pod" "$pod_space" "$pod_status"
else
pod_container_other=""
printf " \\033[%um%s\\033[0m \\033[%um%s\\033[0m\\n" "$PODMAN_OTHER_COLOR" "$PODMAN_OTHER_ICON" "$PODMAN_OTHER_COLOR" "$pod"
fi
pod_status="$pod_container_running$pod_container_other"
printf " \\033[%um%s\\033[0m %s%s%s\\n" "$PODMAN_RUNNING_COLOR" "$PODMAN_RUNNING_ICON" "$pod" "$pod_space" "$pod_status"
else
printf " \\033[%um%s\\033[0m \\033[%um%s\\033[0m\\n" "$PODMAN_OTHER_COLOR" "$PODMAN_OTHER_ICON" "$PODMAN_OTHER_COLOR" "$pod"
fi
done
done
fi
}
print_docker() {
if [ "$(systemctl is-active docker.service)" = "active" ]; then
if type jq > /dev/null && [ "$(systemctl is-active docker.service)" = "active" ]; then
printf "\\n"
printf " \\033[1;37mDocker:\\033[0m\\n"