test
This commit is contained in:
parent
26cb29381b
commit
f64e0cb9a0
35
110-Cleanup.sh
Normal file
35
110-Cleanup.sh
Normal file
@ -0,0 +1,35 @@
|
||||
#!/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"
|
||||
@ -71,6 +71,32 @@ pkgmgr_update(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
get_system_used_space() {
|
||||
echo $(df --output=used -B1 / | tail -n 1| cut -d'%' -f1)
|
||||
}
|
||||
|
||||
pkgmgr_clean(){
|
||||
|
||||
# Get Command language
|
||||
PKG_MANAGER=$( get_pkg_mgr )
|
||||
|
||||
if [ "$PKG_MANAGER" == "apt-get" ] ; then
|
||||
"$PKG_MANAGER" clean
|
||||
"$PKG_MANAGER" autoclean
|
||||
elif [ "$PKG_MANAGER" == "dnf" ] ; then
|
||||
"$PKG_MANAGER" clean dbcache
|
||||
"$PKG_MANAGER" clean all
|
||||
elif [ "$PKG_MANAGER" == "yum" ] ; then
|
||||
"$PKG_MANAGER" clean packages
|
||||
"$PKG_MANAGER" clean headers
|
||||
"$PKG_MANAGER" clean metadata
|
||||
"$PKG_MANAGER" clean all
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
install_pkg() {
|
||||
|
||||
# package to install
|
||||
|
||||
Loading…
Reference in New Issue
Block a user