#!/bin/bash ftpServ="sftp://oscada" ftpOpts="-cnv" lock=/var/run/lock/`basename $0` test -f $lock && kill -0 "$(cat $lock)" 2> /dev/null && echo "Processing is going now!" && exit 0; echo $$ > $lock TargetsList=("/home/roman/work/To\ Do:~/ext/work/To\ Do" "/home/roman/work/Personal:~/ext/work/Personal" "/home/roman/work/Kontact:~/ext/work/Kontact" "/home/roman/work/Projects\ ACS:~/ext/work/Projects\ ACS") # Targets list process iTarg=0 while test "x${TargetsList[iTarg]}" != "x"; do ftpURI_to=`echo ${TargetsList[iTarg]} | sed -n "/^[^/]*.*:\(.*\)/s//\1/p"` if test -z "$ftpURI_to"; then ftpURI=`echo ${TargetsList[iTarg]} | sed -n "/^[^/]*\(.*\)$/s//\1/p"` ftpURI_to=$ftpURI else ftpURI=`echo ${TargetsList[iTarg]} | sed -n "/^[^/]*\(.*\):.*/s//\1/p"` fi #if test $(basename $0) != "workSincFirst"; then echo "Put the local folder '$ftpURI_to' changes to the remote one '$ftpURI' for the server '$ftpServ'" lftp $ftpServ -e "mirror ${ftpOpts}R --only-existing $ftpURI_to $ftpURI; quit" #fi echo "Get the remote folder '$ftpURI' changes to the local one '$ftpURI_to' for the server '$ftpServ'" lftp $ftpServ -e "mirror ${ftpOpts} $ftpURI $ftpURI_to; quit" iTarg=$(($iTarg + 1)) done rm $lock