template_setup/110-Cleanup.sh
deathbybandaid f64e0cb9a0 test
2023-12-17 11:14:22 -05:00

36 lines
958 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 system"
prespace=$( get_system_used_space )
pkgmgr_clean
postspace=$( get_system_used_space )
spacesavedbytes=`expr $postspace - $prespace`
spacesavedbytes=${spacesavedbytes#-}
spacesavedkb=`expr $spacesavedbytes / 1024`
spacesavedmb=`expr $spacesavedbytes / 1024 / 1024`
spacesavedgb=`expr $spacesavedbytes / 1024 / 1024 / 1024`
if [[ "$spacesavedgb" -gt 0 ]]
then
spacesavedwords="$spacesavedgb GB"
elif [[ "$spacesavedmb" -gt 0 ]]
then
spacesavedwords="$spacesavedmb MB"
elif [[ "$spacesavedkb" -gt 0 ]]
then
spacesavedwords="$spacesavedkb KB"
elif [[ "$spacesavedbytes" -gt 0 ]]
then
spacesavedwords="$spacesavedbytes Bytes"
else
spacesavedwords="zero space"
fi
printf "$COL_LIGHT_BLUE" "apt cleanup saved $spacesavedwords"