diff --git a/10-Setting_TimeZone.sh b/010-Setting_TimeZone.sh similarity index 100% rename from 10-Setting_TimeZone.sh rename to 010-Setting_TimeZone.sh diff --git a/15-Setting_locale.sh b/015-Setting_locale.sh similarity index 100% rename from 15-Setting_locale.sh rename to 015-Setting_locale.sh diff --git a/20-Checking_Dependencies.sh b/020-Checking_Dependencies.sh similarity index 100% rename from 20-Checking_Dependencies.sh rename to 020-Checking_Dependencies.sh diff --git a/25-Unattended_Upgrades.sh b/025-Unattended_Upgrades.sh similarity index 100% rename from 25-Unattended_Upgrades.sh rename to 025-Unattended_Upgrades.sh diff --git a/30-Checking_Topgrade_Installation_Status.sh b/030-Checking_Topgrade_Installation_Status.sh similarity index 100% rename from 30-Checking_Topgrade_Installation_Status.sh rename to 030-Checking_Topgrade_Installation_Status.sh diff --git a/35-Runing_Topgrade.sh b/035-Runing_Topgrade.sh similarity index 100% rename from 35-Runing_Topgrade.sh rename to 035-Runing_Topgrade.sh diff --git a/40-Checking_Custom_Bash_Aliases.sh b/040-Checking_Custom_Bash_Aliases.sh similarity index 100% rename from 40-Checking_Custom_Bash_Aliases.sh rename to 040-Checking_Custom_Bash_Aliases.sh diff --git a/50-Tweaking_Systemd_Journalling.sh b/050-Tweaking_Systemd_Journalling.sh similarity index 100% rename from 50-Tweaking_Systemd_Journalling.sh rename to 050-Tweaking_Systemd_Journalling.sh diff --git a/55-Vaccuming_Systemd_Journalling.sh b/055-Vaccuming_Systemd_Journalling.sh similarity index 100% rename from 55-Vaccuming_Systemd_Journalling.sh rename to 055-Vaccuming_Systemd_Journalling.sh diff --git a/60-Updating_Custom_MOTD.sh b/060-Updating_Custom_MOTD.sh similarity index 100% rename from 60-Updating_Custom_MOTD.sh rename to 060-Updating_Custom_MOTD.sh diff --git a/80-Deploy_Netdata.sh b/080-Deploy_Netdata.sh similarity index 100% rename from 80-Deploy_Netdata.sh rename to 080-Deploy_Netdata.sh diff --git a/90-Checking_IPA_Realm_Join_Status.sh b/090-Checking_IPA_Realm_Join_Status.sh similarity index 100% rename from 90-Checking_IPA_Realm_Join_Status.sh rename to 090-Checking_IPA_Realm_Join_Status.sh diff --git a/95-FreeIPA_CA.sh b/095-FreeIPA_CA.sh similarity index 100% rename from 95-FreeIPA_CA.sh rename to 095-FreeIPA_CA.sh diff --git a/110-Cleanup.sh b/110-Cleanup.sh new file mode 100644 index 0000000..3ee83df --- /dev/null +++ b/110-Cleanup.sh @@ -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" diff --git a/common/functions.sh b/common/functions.sh index aadb86c..58ef414 100644 --- a/common/functions.sh +++ b/common/functions.sh @@ -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