mirror of
https://github.com/m8tin/cis.git
synced 2026-08-01 11:47:31 +02:00
composition.shouldBeSyncedByThisHost() extended to composition.shouldBeSyncedByGivenHost() to enable check in sync-send.sh
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
source /cis/core/base.module.sh
|
||||
base.loadModule composition
|
||||
|
||||
|
||||
|
||||
@@ -136,6 +137,10 @@ base.set COMPOSITION "${3}" "${REGEX[COMPOSITION]}"
|
||||
base.set RECEIVERS_SNAPSHOT "${4}" "${REGEX[SNAPSHOT]}" optional
|
||||
base.set RESUME_TOKEN "${5}" '^[a-zA-Z0-9][a-zA-Z0-9._:-]*$' optional
|
||||
|
||||
! composition.shouldBeSyncedByGivenHost "${COMPOSITION}" "${RECEIVERHOST}" \
|
||||
&& echo "FAILURE: The host '${RECEIVERHOST}' is no sync-host for composition: '${COMPOSITION}'" >&2 \
|
||||
&& exit 1
|
||||
|
||||
# Resume mode
|
||||
if [ "${RECEIVERS_SNAPSHOT}" == "@RESUME" ] && [ -n "${RESUME_TOKEN}" ]; then
|
||||
sendResume "${RESUME_TOKEN}"
|
||||
|
||||
@@ -161,7 +161,7 @@ function receiveLoopSingle() {
|
||||
_COMPOSITION="${1:?"receiveLoopSingle(): Missing first parameter COMPOSITION"}"
|
||||
readonly _COMPOSITION
|
||||
|
||||
while composition.shouldBeSyncedByThisHost "${_COMPOSITION}"; do
|
||||
while composition.shouldBeSyncedByGivenHost "${_COMPOSITION}" "${CIS[HOST]}"; do
|
||||
receive "${_COMPOSITION}" \
|
||||
&& echo "Sleep for 5s" \
|
||||
&& sleep 5 \
|
||||
@@ -175,7 +175,7 @@ function receiveLoopSingle() {
|
||||
return 1
|
||||
done
|
||||
|
||||
! composition.shouldBeSyncedByThisHost "${_COMPOSITION}" \
|
||||
! composition.shouldBeSyncedByGivenHost "${_COMPOSITION}" "${CIS[HOST]}" \
|
||||
&& echo "This host '${CIS[HOST]}' is no sync-host (anymore) for composition: '${_COMPOSITION}'"
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ function receiveOnceSingle() {
|
||||
_COMPOSITION="${1:?"receiveOnceSingle(): Missing first parameter COMPOSITION"}"
|
||||
readonly _COMPOSITION
|
||||
|
||||
! composition.shouldBeSyncedByThisHost "${_COMPOSITION}" \
|
||||
! composition.shouldBeSyncedByGivenHost "${_COMPOSITION}" "${CIS[HOST]}" \
|
||||
&& echo "This host '${CIS[HOST]}' is no sync-host for composition: '${_COMPOSITION}'" \
|
||||
&& return 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user