motd.sh: add rootless docker from userlist
This commit is contained in:
parent
e689665674
commit
39b4cdc3c0
16
motd.sh
16
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
|
||||
|
Loading…
Reference in New Issue
Block a user