Update dotfiles/.local/motd.sh
This commit is contained in:
parent
a11873b099
commit
10a5d89f12
1 changed files with 30 additions and 28 deletions
|
@ -399,47 +399,49 @@ print_services() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_podman() {
|
print_podman() {
|
||||||
printf "\\n"
|
if type jq > /dev/null; then
|
||||||
printf " \\033[1;37mPodman:\\033[0m\\n"
|
printf "\\n"
|
||||||
|
printf " \\033[1;37mPodman:\\033[0m\\n"
|
||||||
|
|
||||||
podman_version=$(sudo podman version --format json | jq -r '.Client.Version')
|
podman_version=$(sudo podman version --format json | jq -r '.Client.Version')
|
||||||
podman_space=$(generate_space "$podman_version" 23)
|
podman_space=$(generate_space "$podman_version" 23)
|
||||||
podman_images=$(sudo podman images --format json | jq '. | length')
|
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_list=$(sudo podman pod ls --sort name --format json)
|
||||||
podman_pods=$(echo "$podman_list" | jq -r '.[] .Name')
|
podman_pods=$(echo "$podman_list" | jq -r '.[] .Name')
|
||||||
|
|
||||||
echo "$podman_pods" | while read -r pod; do
|
echo "$podman_pods" | while read -r pod; do
|
||||||
if [ "$(echo "$podman_list" | jq -r ".[] | select(.Name == \"$pod\") | .Status")" = "Running" ]; then
|
if [ "$(echo "$podman_list" | jq -r ".[] | select(.Name == \"$pod\") | .Status")" = "Running" ]; then
|
||||||
pod_space=$(generate_space "$pod" 34)
|
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
|
if [ "$pod_container_running" -ne 0 ]; then
|
||||||
pod_container_running=$(printf "\\033[%um%u Running\\033[0m" "$PODMAN_RUNNING_COLOR" "$pod_container_running")
|
pod_container_running=$(printf "\\033[%um%u Running\\033[0m" "$PODMAN_RUNNING_COLOR" "$pod_container_running")
|
||||||
fi
|
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
|
if [ "$pod_container_other" -ne 0 ]; then
|
||||||
pod_container_other=$(printf ", \\033[%um%u Other\\033[0m" "$PODMAN_OTHER_COLOR" "$pod_container_other")
|
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
|
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
|
fi
|
||||||
|
done
|
||||||
pod_status="$pod_container_running$pod_container_other"
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print_docker() {
|
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 "\\n"
|
||||||
printf " \\033[1;37mDocker:\\033[0m\\n"
|
printf " \\033[1;37mDocker:\\033[0m\\n"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue