diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 1f540b323a..2124ea5383 100644 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -460,12 +460,23 @@ function ssh_make_path { SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null < "\$(dirname $2)/.monitor" - fi +if [ ! -d $2 ]; then + mkdir -p $2 +fi + +# create or update .monitor content +if [ -n "$3" ]; then + MONITOR_FN="\$(dirname $2)/.monitor" + + MONITOR='' + if [ -f "\\${MONITOR_FN}" ]; then + MONITOR="\\$(cat "\\${MONITOR_FN}" 2>/dev/null)" + fi + + if [ "x\\${MONITOR}" != "x$3" ]; then + echo "$3" > "\\${MONITOR_FN}" + fi fi EOF` SSH_EXEC_RC=$? diff --git a/src/tm_mad/ceph/clone b/src/tm_mad/ceph/clone index 6c4705926f..888059eb2a 100755 --- a/src/tm_mad/ceph/clone +++ b/src/tm_mad/ceph/clone @@ -118,7 +118,7 @@ if [ -n "$EC_POOL_NAME" ]; then fi if [ "${TYPE}" = 'FILE' ]; then - ssh_make_path $DST_HOST $DST_DIR + ssh_make_path $DST_HOST $DST_DIR 'ssh' CLONE_CMD=$(cat </dev/null || : +fi +EOF +) + +MONITOR=$(ssh_monitor_and_log "$SRC_HOST" "$MONITOR_CMD" 'Get .monitor') + +ssh_make_path "$DST_HOST" "$DST_PATH" "$MONITOR" log "Moving $SRC to $DST"