Compare commits

...

3 Commits

Author SHA1 Message Date
saundersp
33a93135bc README.md : removed docker total size for each metrics command 2024-06-28 19:13:43 +02:00
saundersp
1f6fcc4a8c Prettier pull.sh 2024-06-28 19:12:05 +02:00
saundersp
1ac15f047d Added colours script 2024-06-28 19:11:52 +02:00
3 changed files with 60 additions and 7 deletions

View File

@ -36,9 +36,7 @@ docker volume ls --format="{{.Name}}" | xargs docker volume rm
docker images --format="{{.Repository}};{{.Tag}};{{.ID}}" | grep "<none>;<none>" | cut -d";" -f 3 | xargs docker rmi docker images --format="{{.Repository}};{{.Tag}};{{.ID}}" | grep "<none>;<none>" | cut -d";" -f 3 | xargs docker rmi
# Get all used images tag in dir $PATH_ANALYSE # Get all used images tag in dir $PATH_ANALYSE
find $PATH_ANALYSE -name "Dockerfile*" | while read file; do cat $file; echo ""; done | grep -e FROM | cut -d " " -f 2 | sed $'s/[^[:print:]\t]//g' | sort -u | xargs -n1 docker pull find $PATH_ANALYSE -name "Dockerfile*" | while read file; do cat $file; echo ""; done | grep -e FROM | cut -d " " -f 2 | sed $'s/[^[:print:]\t]//g' | sort -u | xargs -n1 docker pull
# Calculate total docker images for each metrics # Calculate total docker images size
docker images --format {{.Size}} | grep MB | cut -d M -f 1 | paste -sd+ | bc
docker images --format {{.Size}} | grep GB | cut -d G -f 1 | paste -sd+ | bc
docker images --format {{.ID}} | xargs -n1 docker inspect | jq '.[0]["Size"]' | paste -sd + | bc | format_bytes_str docker images --format {{.ID}} | xargs -n1 docker inspect | jq '.[0]["Size"]' | paste -sd + | bc | format_bytes_str
``` ```

33
colours Executable file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Print out escape sequences usable for coloured text on tty.
printf 'Colour escapes are %s\n' '\e[${value};...;${value}m'
printf 'Values 30..37 are \e[33mforeground colours\e[m\n'
printf 'Values 40..47 are \e[43mbackground colours\e[m\n'
printf 'Value 1 gives a \e[1mbold look\e[m\n'
printf 'Value 2 gives a \e[2mdim look\e[m\n'
printf 'Value 3 gives a \e[3mitalic look\e[m\n'
printf 'Value 4 gives a \e[4munderlined look\e[m\n'
printf 'Value 5 gives a \e[5mblinking look\e[m\n\n'
# foreground colours
for fgc in {30..37}; do
# background colours
for bgc in {40..47}; do
fgc=${fgc#37} # white
bgc=${bgc#40} # black
vals="${fgc:+$fgc;}${bgc}"
vals=${vals%%;}
seq0="${vals:+\e[${vals}m}"
printf " %-9s" "${seq0:-(default)}"
echo -e -n " ${seq0}TEXT\e[m"
echo -e -n " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
echo -e -n " \e[${vals:+${vals+$vals;}}2mDIM\e[m"
echo -e -n " \e[${vals:+${vals+$vals;}}3mITA\e[m"
echo -e -n " \e[${vals:+${vals+$vals;}}4mUND\e[m"
echo -e -n " \e[${vals:+${vals+$vals;}}5mBLI\e[m"
done
echo; echo
done

30
pull.sh
View File

@ -1,13 +1,35 @@
#!/bin/sh #!/bin/sh
__r__(){
end="$1"
for _ in $(seq 1 "$end"); do
printf '%s' "$2";
done
}
cd .. cd ..
for d in *; do for d in *; do
echo "current directory: $d" cd "$d" || continue
cd "$d"
# git pull #PULL_LOG=$(script -q /dev/null -c 'git pull')
#if [ "$PULL_LOG" != "$(env printf 'Already up to date.\r\n')" ]; then
# env printf "┌$(__r__ 40 ─)┐\n"
# env printf "│ %-38s │\n" "$d"
# env printf "└$(__r__ 40 '─')┘\n"
# echo "$PULL_LOG"
#fi
# git gc # git gc
# git clean -fx # git clean -fx
git status -s
STATUS_LOG=$(script -q /dev/null -c 'git status -s')
if [ -n "$STATUS_LOG" ]; then
env printf "$(__r__ 40)┐\n"
env printf "│ %-38s │\n" "$d"
env printf "$(__r__ 40 '─')┘\n"
echo "$STATUS_LOG"
fi
cd .. cd ..
done done