diff --git a/masync b/masync index a54c31f..30a952e 100755 --- a/masync +++ b/masync @@ -136,6 +136,10 @@ startsyncpath() { loopsyncpath $1 } +readlog() { + tail -f ~/syncloop_$1.nohup +} + loopsyncpath() { echo -e "Starting loop for synching ${GREEN}$1${ENDCOLOR}" re_num='^[0-9]+$' @@ -338,6 +342,53 @@ case "$1" in esac done ;; + status) + shift + while getopts ":l:s:" option; do + case "${option}" in + l) localsync=${OPTARG} + if [[ -d "$localsync" ]]; then + synce=$(syncexists ${localsync}) + if [ ${synce} = true ]; then + echo "Read log related to local folder ${localsync}" + grep ${localsync} $SYNCFILE | while read hash pid when status localpath remotepath; do + readlog ${hash} + done + else + echo "local folder ${localsync} not in sync task, you can not read the log" + fi + else + echo "ATTENTION $localsync not exists Aborting log!" + exit 2 + fi + ;; + s) indexsync=${OPTARG} + empty=$(emptysyncfile) + if [ ${empty} = true ]; then + echo "Sync ${indexsync} not exists, sync file empty, please use init first" + else + re_num='^[0-9]+$' + if [[ ! $indexsync =~ $re_num ]]; then + echo -e "-s option must be ${RED}integer${ENDCOLOR}" + exit 3 + fi + oi=$(syncoutofindex $indexsync) + if [ ${oi} = true ]; then + echo "Sync ${indexsync} out of index" + exit 1 + else + sed -n -s "$indexsync"p "$SYNCFILE" | while read hash pid when status localpath remotepath; do + readlog ${hash} + done + fi + fi + ;; + \?) myhelp + exit 1 + ;; + esac + done + ;; stop) shift while getopts ":l:s:" option; do