#!/bin/bash
# 将数据分发给集群内所有机器

source="$1"
if [ -e "$2" ];then
    target="$2"
else
    target="$1"
fi

if [ -z "$SSH" ];then
    source /unas/sbin/dualcontroller/config/prepare
fi

if [ -z "$IPS" ];then
    IPS=(`grep -o 'ring1_addr: .*' /etc/corosync/corosync.conf | awk '{print $2}'`)
fi

for h in "${IPS[@]}";do
    if [ "$source" == "$target" ] && ip a | grep -qw "$h";then
        echo Skip self
    else
        rsync -avz --delete -e "$SSH" "$source" "root@$h":"$target"
    fi
done

