Skip to content

Commit b5438dd

Browse files
linup2011sopos
andauthored
sync: SERVERS and CLIENTS support multiple servers and clients (#7)
* sync: SERVERS and CLIENTS support multiple servers and clients Co-authored-by: Dalibor Pospíšil <[email protected]>
1 parent f5059e0 commit b5438dd

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

sync/lib.sh

+35-14
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,10 @@ syncLibraryLoaded() {
762762
# find client and server in the roles
763763
case ,${role^^},${name^^}, in
764764
*,SERVER,*)
765-
syncHostServerRoleIndex=$i
765+
syncHostServerRoleIndex+=( $i )
766766
;;
767767
*,CLIENT,*)
768-
syncHostClientRoleIndex=$i
768+
syncHostClientRoleIndex+=( $i )
769769
;;
770770
esac
771771

@@ -803,21 +803,42 @@ syncLibraryLoaded() {
803803
done
804804

805805
# reset compatibility variables
806+
806807
[[ -n "$syncHostServerRoleIndex" ]] && {
807-
export SERVERS="${syncHostHostname[$syncHostServerRoleIndex]}"
808-
export syncSERVER="${syncHost[$syncHostServerRoleIndex]}"
809-
export syncSERVER_IP="${syncHostIP[$syncHostServerRoleIndex]}"
810-
export syncSERVERv6="${syncHostIPv6[$syncHostServerRoleIndex]}"
811-
export syncSERVER_IPv6="${syncSERVERv6}"
812-
export syncSERVER_HOSTNAME="${syncHostHostname[$syncHostServerRoleIndex]}"
808+
SERVERS=''
809+
syncSERVER_HOSTNAME=()
810+
syncSERVER=()
811+
syncSERVER_IP=()
812+
syncSERVERv6=()
813+
syncSERVER_IPv6=()
814+
for i in "${syncHostServerRoleIndex[@]}"; do
815+
SERVERS+=" ${syncHostHostname[$i]}"
816+
syncSERVER_HOSTNAME+=( "${syncHostHostname[$i]}" )
817+
syncSERVER+=( "${syncHost[$i]}" )
818+
syncSERVER_IP+=( "${syncHostIP[$i]}" )
819+
syncSERVERv6+=( "${syncHostIPv6[$i]}" )
820+
syncSERVER_IPv6+=( "${syncHostIPv6[$i]}" )
821+
done
822+
SERVERS="${SERVERS:1}"
823+
export SERVERS syncSERVER syncSERVER_IP syncSERVERv6 syncSERVER_IPv6 syncSERVER_HOSTNAME
813824
}
814825
[[ -n "$syncHostClientRoleIndex" ]] && {
815-
export CLIENTS="${syncHostHostname[$syncHostClientRoleIndex]}"
816-
export syncCLIENT="${syncHost[$syncHostClientRoleIndex]}"
817-
export syncCLIENT_IP="${syncHostIP[$syncHostClientRoleIndex]}"
818-
export syncCLIENTv6="${syncHostIPv6[$syncHostClientRoleIndex]}"
819-
export syncCLIENT_IPv6="${syncCLIENTv6}"
820-
export syncCLIENT_HOSTNAME="${syncHostHostname[$syncHostClientRoleIndex]}"
826+
CLIENTS=''
827+
syncCLIENT_HOSTNAME=()
828+
syncCLIENT=()
829+
syncCLIENT_IP=()
830+
syncCLIENTv6=()
831+
syncCLIENT_IPv6=()
832+
for i in "${syncHostClientRoleIndex[@]}"; do
833+
CLIENTS+=" ${syncHostHostname[$i]}"
834+
syncCLIENT_HOSTNAME+=( "${syncHostHostname[$i]}" )
835+
syncCLIENT+=( "${syncHost[$i]}" )
836+
syncCLIENT_IP+=( "${syncHostIP[$i]}" )
837+
syncCLIENTv6+=( "${syncHostIPv6[$i]}" )
838+
syncCLIENT_IPv6+=( "${syncHostIPv6[$i]}" )
839+
done
840+
CLIENTS="${CLIENTS:1}"
841+
export CLIENTS syncCLIENT syncCLIENT_IP syncCLIENTv6 syncCLIENT_IPv6 syncCLIENT_HOSTNAME
821842
}
822843

823844
# get default GW interface

0 commit comments

Comments
 (0)