1
0
mirror of https://github.com/namibia/demo-sync.git synced 2024-11-21 19:15:10 +00:00

Added the logic for the syncFolder method.

This commit is contained in:
Llewellyn van der Merwe 2020-03-06 18:43:29 +02:00
parent 7fe7fef244
commit f8898a29cf
No known key found for this signature in database
GPG Key ID: 8A8F406BA7238C4E

19
sync.sh
View File

@ -151,6 +151,8 @@ function setCron () {
fi fi
# set the user cron # set the user cron
crontab -u $ACTIVEUSER "${CRONPATH}" crontab -u $ACTIVEUSER "${CRONPATH}"
# close the block
echo -e "\n ################################################################################################"
fi fi
} }
@ -370,10 +372,19 @@ function syncFolders (){
### sync folder ### ### sync folder ###
function syncFolder (){ function syncFolder (){
local source_folder="$1" local source_folder=$(realpath -s $1)
local target_folder="$2" local target_folder=$(realpath -s $2)
# get the owners
echo "${source_folder}" "${target_folder}" local source_owner=$(stat -c '%U' "${source_folder}")
local target_owner=$(stat -c '%U' "${target_folder}")
# give the user log data
echoTweak "Syncing folders of [${source_owner}] with [${target_owner}]..."
# we use rsync to do all the sync work (very smart)
rsync -qrd --delete "${source_folder}/" "${target_folder}"
# run chown again (will only work if script run as root)
chown -R "${target_owner}":"${target_owner}" "${target_folder}/"*
# done :)
echo "done"
} }
############################################################## ##############################################################