From 1bc2bdd610e22eff01eb0441012839681ad20062 Mon Sep 17 00:00:00 2001 From: Daniel Sosnowski Date: Thu, 4 Dec 2025 15:01:57 +0100 Subject: [PATCH] Fixed --- clearCache.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 clearCache.sh diff --git a/clearCache.sh b/clearCache.sh new file mode 100644 index 0000000..3fb72f6 --- /dev/null +++ b/clearCache.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +declare -i diskUsage +vhostDir="/var/www/vhosts" + +diskUsage=$(df -h / | grep /dev | awk '{print $5}' | cut -d% -f1) +if [[ $diskUsage -ge 50 ]] +then + + cd "$vhostDir" + + find . -maxdepth 1 -name "*.decostores.*" > "/tmp/subscriptions.txt" + echo -e "Wykryto subskrypcje:\n" + cat /tmp/subscriptions.txt | cut -d/ -f2 + readarray -t subscriptionList < /tmp/subscriptions.txt + + echo -e "\n" + echo -e "Rozpoczynam czyszczenie cache...\n" + + for subscription in "${subscriptionList[@]}" + do + for path in "$subscription/httpdocs/shopsystem/application/cache/boxes"* "$subscription/httpdocs/shopsystem/appcation/cache/smarty_compiled" + do + + if [[ -d "$path" ]] + then + cd "$path" + echo -e "CzyszczÄ™ cache w subskrybcji $subscription...\n" + ls -1 > "/tmp/dirList.txt" + readarray -t dirList < /tmp/dirList.txt + for dir in "${dirList[@]}" + do + if [[ -d "$dir" ]] + then + echo -e "Czyszczenie $dir...\n" + cd "$dir" + ls -1 + cd .. + fi + done + fi + cd "$vhostDir" + done + done +fi + +if [[ -f "/tmp/subscriptions.txt" ]] && [[ -f "/tmp/dirList.txt" ]] +then + rm -r "/tmp/subscriptions.txt" "/tmp/dirList.txt" +fi