Add docker to motd.sh

This commit is contained in:
Alice Gaudon 2022-06-23 09:26:07 +02:00
parent 695dd52dc8
commit d6a1b3ef6a

16
motd.sh
View File

@ -54,6 +54,22 @@ printf "\nServices:\n"
printf "$out" | column -ts $',' | sed -e 's/^/ /' printf "$out" | column -ts $',' | sed -e 's/^/ /'
### Docker ###
containers=($(docker ps -a --format "{{.Image}} / {{.Names}}"))
container_statuses=($(docker ps -a --format "{{.State}}"))
out=""
for i in ${!containers[@]}; do
if [[ "${container_statuses[$i]}" == "running" ]]; then
out+="${containers[$i]}:,${green}${container_statuses[$i]}${undim},"
else
out+="${containers[$i]}:,${red}${container_statuses[$i]}${undim},"
fi
out += "\n"
done
printf "\nDocker:\n"
printf "$out" | column -ts $',' | sed -e 's/^/ /'
### Disk space ### ### Disk space ###
# config # config
max_usage=80 max_usage=80