From f1385304ebd202e50b053eec52f4b8bfc3118a1c Mon Sep 17 00:00:00 2001 From: timoxa0 Date: Sun, 3 Nov 2024 16:38:26 +0500 Subject: [PATCH] functions: Add clean cache function --- common.d/functions.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common.d/functions.sh b/common.d/functions.sh index 6b61366..a0f65d9 100644 --- a/common.d/functions.sh +++ b/common.d/functions.sh @@ -82,6 +82,10 @@ arguments() { cleanraw exit $? ;; + -w | --cleancache) + cleancache + exit $? ;; + -h | -help | --help) usage exit $? ;; @@ -107,6 +111,9 @@ usage() { # Clean raw images $0 --cleanraw or -r + # Clean cache + $0 --cleancache or -w + # Build LNIBUILD $0 EOF @@ -142,6 +149,15 @@ cleanraw() rm ./raw/* -f && log "Done!" } +cleancache() +{ + find ./cache/ -mindepth 1 -maxdepth 1 | read || { + [ -z ${quiet+x} ] && log "Nothing to clean" error + return 0 + } + rm ./cache/* -f && log "Done!" +} + # shellcheck disable=SC2317 _shutdown() {