test
This commit is contained in:
parent
f64e0cb9a0
commit
0177c45b28
@ -7,29 +7,14 @@ source "$SCRIPTDIR/common/functions.sh"
|
|||||||
source "$SCRIPTDIR/common/load-defaults.sh"
|
source "$SCRIPTDIR/common/load-defaults.sh"
|
||||||
|
|
||||||
printf "$COL_LIGHT_BLUE" "* Cleaning up system"
|
printf "$COL_LIGHT_BLUE" "* Cleaning up system"
|
||||||
prespace=$( get_system_used_space )
|
prespace= $( get_system_used_space )
|
||||||
|
prespacewords= $(human_readable_bytes $prespace)
|
||||||
|
printf "$COL_LIGHT_BLUE" "* Current used space is $prespacewords"
|
||||||
pkgmgr_clean
|
pkgmgr_clean
|
||||||
postspace=$( get_system_used_space )
|
postspace= $( get_system_used_space )
|
||||||
|
postspacewords= $(human_readable_bytes $prespace)
|
||||||
|
printf "$COL_LIGHT_BLUE" "* Current used space is now $postspacewords"
|
||||||
|
|
||||||
spacesavedbytes=`expr $postspace - $prespace`
|
spacesavedbytes=`expr $postspace - $prespace`
|
||||||
spacesavedbytes=${spacesavedbytes#-}
|
postspacewords= $(human_readable_bytes $spacesavedbytes)
|
||||||
spacesavedkb=`expr $spacesavedbytes / 1024`
|
printf "$COL_LIGHT_BLUE" "Cleanup saved $spacesavedwords"
|
||||||
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"
|
|
||||||
|
|||||||
@ -76,11 +76,36 @@ get_system_used_space() {
|
|||||||
echo $(df --output=used -B1 / | tail -n 1| cut -d'%' -f1)
|
echo $(df --output=used -B1 / | tail -n 1| cut -d'%' -f1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
human_readable_bytes() {
|
||||||
|
local spacebytes="$1"
|
||||||
|
spacekb=`expr $spacebytes / 1024`
|
||||||
|
spacemb=`expr $spacebytes / 1024 / 1024`
|
||||||
|
spacegb=`expr $spacebytes / 1024 / 1024 / 1024`
|
||||||
|
|
||||||
|
if [[ "$spacegb" -gt 0 ]]
|
||||||
|
then
|
||||||
|
spacewords="$spacegb GB"
|
||||||
|
elif [[ "$spacemb" -gt 0 ]]
|
||||||
|
then
|
||||||
|
spacewords="$spacemb MB"
|
||||||
|
elif [[ "$spacekb" -gt 0 ]]
|
||||||
|
then
|
||||||
|
spacewords="$spacekb KB"
|
||||||
|
elif [[ "$spacebytes" -gt 0 ]]
|
||||||
|
then
|
||||||
|
spacewords="$spacebytes Bytes"
|
||||||
|
else
|
||||||
|
spacewords="zero space"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
pkgmgr_clean(){
|
pkgmgr_clean(){
|
||||||
|
|
||||||
# Get Command language
|
# Get Command language
|
||||||
PKG_MANAGER=$( get_pkg_mgr )
|
PKG_MANAGER=$( get_pkg_mgr )
|
||||||
|
|
||||||
|
printf "$COL_YELLOW" "Cleaning cache for $PKG_MANAGER"
|
||||||
|
|
||||||
if [ "$PKG_MANAGER" == "apt-get" ] ; then
|
if [ "$PKG_MANAGER" == "apt-get" ] ; then
|
||||||
"$PKG_MANAGER" clean
|
"$PKG_MANAGER" clean
|
||||||
"$PKG_MANAGER" autoclean
|
"$PKG_MANAGER" autoclean
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user