From 2fef0bc78fcdbaa177bb68b88a05dd20c8fb0405 Mon Sep 17 00:00:00 2001 From: LuluTchab Date: Thu, 16 Nov 2017 14:22:48 +0100 Subject: [PATCH] now handles multiple WP sites --- bin/clean.sh | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/bin/clean.sh b/bin/clean.sh index 3018be65b..7580c8a55 100755 --- a/bin/clean.sh +++ b/bin/clean.sh @@ -2,25 +2,33 @@ htDocsDir=`find volumes/srv/$1/ -name htdocs` - -# If 'htdocs' folder found, +# If one or more 'htdocs' folder found, if [ "${htDocsDir}" != "" ] -then +then + + # looping through 'htdocs' folder found using FD 9 (http://mywiki.wooledge.org/BashFAQ/089) + while read -r path <&9 + do + echo -n "Following folder will be deleted, please confirm (${path}) - (yes/no): " + read -r answer + + + if [ "${answer}" = "yes" ] + then + echo "Cleaning WP files ($path)..." + if [ -e ${path} ] + then + sudo rm -r ${path} + fi + else + echo "Skipping WP files deletion!" + fi + + done 9<<< "${htDocsDir}" + - echo -n "Following folder will be deleted, please confirm (${htDocsDir}) - (yes/no): " - read answer - if [ "${answer}" = "yes" ] - then - echo "Cleaning WP files..." - if [ -e ${htDocsDir} ] - then - sudo rm -r ${htDocsDir} - fi - else - echo "Skipping WP files deletion!" - fi else echo "WP files already cleaned!" @@ -34,4 +42,3 @@ then else echo "DB files already cleaned!" fi -