#Variable with date
Now_date=`date +%Y%m%d`
#adding source for an original configuration file
source=/home/bin/custome.conf
#adding varibale to create a copy of original file with date stamp and coping it
customize="$source-$Now_date"
cp -af -- "$source" "$customize"
#Adding massive with folders
folders=( "Accounts" "Salary" "Taxes" "Review" "Data")
#Launching script by folderds
for group in ${folders[@]}; do
#That a variable for a string we replace
DIR_INCOMING_REMOTE="/incoming/deltas-${Now_date}/${folders}"
#replacing configuration string in the file /home/bin/custome.conf
sed -i "/DIR_INCOMING_REMOTE/s|.*|export DIR_INCOMING_REMOTE='${DIR_INCOMING_REMOTE}'|g;" "$customize"
#Launching external script which processing $customize.conf file(now it looks like customize.conf-20200206) and checking for ok message
./external_script.sh "$customize" && { echo "exiting fine"; continue; } || { echo "failed"; break; }
done
But i dont know how to add next condition to run the script for every folder only in case if folder exists and the folders are on the remote server:
if ssh 192.168.101.10 '[ -d /home/incoming/deltas-${Now_date}/${folders} ]'
then
{
# perform directory check exist for /home/incoming/deltas-20200206/Salary and than run script. the same for other folders, if folder not exists, just skip folder upload. It will run in cron and check for folder creation and than execute script for a next folder.
}
fi