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

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

if [ -z "$1" ];then
    for h in "${IPS[@]}";do
        echo $h
    done
else
    for h in "${IPS[@]}";do
        if [ "$SKIP_SELF"n != 1n ] || ! ip a | grep -qw "$h";then
            $SSH "root@$h" -- "$@"
        fi
    done
fi
