logging
This commit is contained in:
parent
e2d2d92e95
commit
1bf9a20e74
16
syncloop.sh
16
syncloop.sh
@ -63,9 +63,9 @@ synccycle() {
|
||||
if [ -f "$TMPQUEUEDELETES" ]; then
|
||||
ndeletes=$(wc -l < ${TMPQUEUEDELETES})
|
||||
while [ $ndeletes -gt 0 ]; do
|
||||
echo -n -e "${PURPLE}[PUSH FILES TO DELETE]${ENDCOLOR} to remote: ${RED}$(head -n $ndeletes ${TMPQUEUEDELETES} | tr '\n', ' ')${ENDCOLOR}..."
|
||||
echo -n -e "[Masync log - PUSH FILES TO DELETE] to remote: ${RED}$(head -n $ndeletes ${TMPQUEUEDELETES} | tr '\n', ' ')${ENDCOLOR}"
|
||||
ssh $REMOTEHOST "rm -rf $(head -n $ndeletes ${TMPQUEUEDELETES} | tr '\n', ' ')"
|
||||
echo -e " ${GREEN}DONE${ENDCOLOR}"
|
||||
echo -e " ${PURPLE}DONE${ENDCOLOR}"
|
||||
# remove the first ndeletes lines
|
||||
flock $lock_deletes
|
||||
tmpfile=$(mktemp)
|
||||
@ -82,9 +82,9 @@ synccycle() {
|
||||
nqueue=$(wc -l < ${TMPQUEUEFILE})
|
||||
while [ $nqueue -gt 0 ]; do
|
||||
#echo "${TMPQUEUEFILE} not empty consume ${nqueue} updates in queue"
|
||||
echo -n -e "${PURPLE}[PUSH FILES]${ENDCOLOR} to remote: ${GREEN}$(head -n ${nqueue} ${TMPQUEUEFILE} | tr '\n', ' ')${ENDCOLOR}..."
|
||||
echo -n -e "[Masync log - PUSH FILES] to remote: ${GREEN}$(head -n ${nqueue} ${TMPQUEUEFILE} | tr '\n', ' ')${ENDCOLOR}"
|
||||
sync $LOCALPATH_HASH $LOCALPATH $REMOTEPATH
|
||||
echo -e " ${GREEN}DONE${ENDCOLOR}"
|
||||
echo -e " ${PURPLE}DONE${ENDCOLOR}"
|
||||
# remove the first nqueue lines from queue
|
||||
flock $lock_queue
|
||||
tmpfile=$(mktemp)
|
||||
@ -101,9 +101,9 @@ synccycle() {
|
||||
elapsed="$(bc <<<"$now-$lastsynctime")"
|
||||
## if elapsed is greater than maxpulllimit sync from remote with delete option
|
||||
if [ 1 -eq $(echo "$elapsed>$maxpulllimit" | bc) ]; then
|
||||
echo -n -e "${PURPLE}[PULL LIMIT REACHED]${ENDCOLOR} $maxpulllimit seconds reached: sync from remote with --delete option..."
|
||||
echo -n "[Masync log - PULL LIMIT reached] $maxpulllimit seconds reached: sync from remote with --delete option..."
|
||||
sync $LOCALPATH_HASH $REMOTEPATH $LOCALPATH '--delete'
|
||||
echo -e " ${GREEN}DONE${ENDCOLOR}"
|
||||
echo -e " ${PURPLE}DONE${ENDCOLOR}"
|
||||
lastsynctime="$(date -u +%s.%N)"
|
||||
## increment the pull iteration or reset it
|
||||
if [ ${pulliteration} -eq ${maxpulliteration} ]; then
|
||||
@ -123,7 +123,7 @@ synccycle &
|
||||
# exclude swp,swpx and 4913 files created by vim
|
||||
inotifywait -m -r -e create -e close_write -e move -e delete --exclude "\.swp|\.swx|4913|.txt~" $LOCALPATH | while read dir action file; do
|
||||
if [ $action = 'DELETE' ] || [ $action = 'DELETE,ISDIR' ] || [ $action = 'MOVED_FROM' ] || [ $action = 'MOVED_FROM,ISDIR' ]; then
|
||||
echo -e "${PURPLE}[ENQUEUE delete]${ENDCOLOR} $dir$file"
|
||||
echo -e "[Masync log - ENQUEUE delete] $dir$file"
|
||||
flock $lock_deletes
|
||||
echo $dir$file | sed -e "s~$LOCALPATH~$REMOTERELATIVEPATH~g" | tee -a ${TMPQUEUEDELETES} 1>/dev/null
|
||||
flock -u $lock_deletes
|
||||
@ -132,7 +132,7 @@ inotifywait -m -r -e create -e close_write -e move -e delete --exclude "\.swp|\.
|
||||
## add to queue only if not already in it
|
||||
if [ $(grep -E ${file}$ ${TMPQUEUEFILE} | wc -l) -lt 1 ]; then
|
||||
#echo "Add notify to queue: file '$file' in directory '$dir' for '$action'" | tee -a ${TMPQUEUEFILE}
|
||||
echo -e "${PURPLE}[ENQUEUE file]${ENDCOLOR} $dir$file"
|
||||
echo -e "[Masync log - ENQUEUE file] $dir$file"
|
||||
# AVOID TO USE TEE: SIMPLY append
|
||||
#echo ${dir}${file} | tee -a ${TMPQUEUEFILE}
|
||||
echo ${dir}${file} >> ${TMPQUEUEFILE}
|
||||
|
Loading…
Reference in New Issue
Block a user