Logger "Remote lock is: $lock_pid@$lock_sync_id""DEBUG"
ps -p$lock_pid > /dev/null 2>&1
if[$? !=0];then
if["$lock_sync_id"=="$SYNC_ID"];then
Logger "There is a dead osync lock on target replica that corresponds to this initiator sync id [$lock_sync_id]. Instance [$lock_pid] no longer running. Resuming.""NOTICE"
else
if["$FORCE_STRANGER_LOCK_RESUME"=="yes"];then
Logger "WARNING: There is a dead osync lock on target replica that does not correspond to this initiator sync-id [$lock_sync_id]. Forcing resume.""WARN"
else
Logger "There is a dead osync lock on target replica that does not correspond to this initiator sync-id [$lock_sync_id]. Will not resume.""CRITICAL"
exit1
fi
fi
else
Logger "There is already a local instance of osync that locks target replica [$lock_pid@$lock_sync_id]. Cannot start.""CRITICAL"
exit1
fi
fi
}
}
function CheckLocks {
function CheckLocks {
@ -1133,6 +1181,8 @@ function CheckLocks {
else
else
_CheckLocksRemote "$TARGET_LOCKFILE"
_CheckLocksRemote "$TARGET_LOCKFILE"
fi
fi
WriteLockFiles
}
}
function LockDirectories {
function LockDirectories {
@ -1203,7 +1253,52 @@ function LockDirectories {
WriteLockFiles
WriteLockFiles
}
}
function UnlockDirectories {
function _UnlockReplicasLocal {
locallockfile="${1}"
__CheckArguments 1$#$FUNCNAME"$*"
if[ -f "$lockfile"];then
$COMMAND_SUDO rm "$lockfile"
if[$? !=0];then
Logger "Could not unlock local replica.""ERROR"
else
Logger "Removed local replica lock.""NOTICE"
fi
fi
}
function _UnlockReplicasRemote {
locallockfile="${1}"
__CheckArguments 1$#$FUNCNAME"$*"
CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost
cmd="$SSH_CMD \"if [ -f \\\"$localfile\\\" ]; then $COMMAND_SUDO rm \\\"$lockfile\\\"; fi 2>&1\"" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID&