add statistics

This commit is contained in:
Cheri Dawn 2024-07-20 17:16:53 +03:00
parent 98b731a0d0
commit 267a7a6c72

23
doit
View file

@ -35,14 +35,35 @@ runsync() {
rsync -have ssh $OUTPATH/ $SERVPATH rsync -have ssh $OUTPATH/ $SERVPATH
} }
while getopts "bcs" flag; do dostats() {
[ -d $OUTPATH ]
echo -e "Used space:"
echo -e " ├── content: $(du -hs content | cut -f1)"
echo -e " ├── output: $(du -hs $OUTPATH | cut -f1)"
echo -e " └── all: $(du -hs . | cut -f1)"
echo
echo -e "File types:"
echo -e " ├── total: $(find $OUTPATH -type f | wc -l)"
echo -e " ├── total known: $(find $OUTPATH -type f | grep -iE '\.(jpg|png|webp|gif|ico|css|php|html)' | wc -l)"
echo -e " ├── HTML: $(find $OUTPATH -type f -iname '*.html' | wc -l)"
echo -e " ├── CSS: $(find $OUTPATH -type f -iname '*.css' | wc -l)"
echo -e " ├── PHP: $(find $OUTPATH -type f -iname '*.php' | wc -l)"
echo -e " ├── images: $(find $OUTPATH -type f | grep -iE '\.(jpg|png|webp|gif|ico)' | wc -l)"
echo -e " └── other:"
find $OUTPATH -type f | rev | cut -d. -f1 | rev | sort | uniq -c | grep -viE 'html|css|php|jpg|png|webp|gif|ico' | awk '{ print " ├── " $2 ": " $1 }'
echo -e " └── total: $(find $OUTPATH -type f | rev | cut -d. -f1 | rev | sort | grep -viE 'html|php|jpg|png|webp|gif|css|ico' | wc -l)"
}
while getopts "bcsS" flag; do
case ${flag} in case ${flag} in
b) dobuild=y;; b) dobuild=y;;
c) doclean=y;; c) doclean=y;;
s) dosync=y;; s) dosync=y;;
S) dostats=y;;
esac esac
done done
[ -v doclean ] && rm -rfv output ||: [ -v doclean ] && rm -rfv output ||:
[ -v dobuild ] && runbuild [ -v dobuild ] && runbuild
[ -v dosync ] && runsync || true [ -v dosync ] && runsync || true
[ -v dostats ] && dostats