template_setup/212-Cleanup_Old_Dockers.sh
deathbybandaid c3a2fb9ab9 test
2024-05-01 22:26:39 -04:00

29 lines
855 B
Bash

#!/bin/bash
## Script Location
SCRIPTDIR=$(dirname $0)
source "$SCRIPTDIR/common/colors.sh"
source "$SCRIPTDIR/common/functions.sh"
source "$SCRIPTDIR/common/load-defaults.sh"
printf "$COL_LIGHT_BLUE" "* Cleaning up old dockers"
if is_command "docker";
then
prespace=$(get_system_used_space)
prespacewords=$(human_readable_bytes "$prespace")
printf "$COL_LIGHT_BLUE" "* Current used space is $prespacewords"
docker system prune -a
postspace=$(get_system_used_space)
postspacewords=$(human_readable_bytes "$prespace")
printf "$COL_LIGHT_BLUE" "* Current used space is now $postspacewords"
spacesavedbytes=`expr $postspace - $prespace`
spacesavedwords=$(human_readable_bytes "$spacesavedbytes")
printf "$COL_LIGHT_BLUE" "* Cleanup saved $spacesavedwords"
else
printf "$COL_LIGHT_BLUE" "* docker is not enabled on this system"
fi