diff --git a/110-Cleanup.sh b/110-Cleanup_Package_Manger.sh similarity index 100% rename from 110-Cleanup.sh rename to 110-Cleanup_Package_Manger.sh diff --git a/111-Cleanup_Old_Snaps.sh b/111-Cleanup_Old_Snaps.sh new file mode 100644 index 0000000..03ff2ff --- /dev/null +++ b/111-Cleanup_Old_Snaps.sh @@ -0,0 +1,33 @@ +#!/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 snaps" + +if is_command "snap"; +then + prespace=$(get_system_used_space) + prespacewords=$(human_readable_bytes "$prespace") + printf "$COL_LIGHT_BLUE" "* Current used space is $prespacewords" + + set -eu + LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' | + while read snapname revision; do + snap remove "$snapname" --revision="$revision" + done + snap set system refresh.retain=2 + + 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" "* Snap is not enabled on this system" +fi diff --git a/112-Cleanup_Old_Dockers.sh b/112-Cleanup_Old_Dockers.sh new file mode 100644 index 0000000..5f705df --- /dev/null +++ b/112-Cleanup_Old_Dockers.sh @@ -0,0 +1,28 @@ +#!/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" "* Snap is not enabled on this system" +fi