diff --git a/motd.sh b/motd.sh index 3880e8e..40e7659 100755 --- a/motd.sh +++ b/motd.sh @@ -69,6 +69,22 @@ done printf "\nDocker:\n" printf "$out" | column -ts $',' | sed -e 's/^/ /' +rootless_users=($(cat /.motd.users)) +for user in ${rootless_users[@]}; do + containers=($(sudo -n DOCKER_HOST=unix:///run/user/$(id -u $user)/docker.sock docker ps --format "{{.Image}}/{{.Names}}")) + container_statuses=($(sudo -n DOCKER_HOST=unix:///run/user/$(id -u $user)/docker.sock docker ps --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 > $user:\n" + printf "$out" | column -ts $',' | sed -e 's/^/ /' +done ### Disk space ### # config