
#改变工作目录到当前脚本所在路径
if [[ "$0" =~ / ]]; then cd "${0%/*}"; fi

args="$* "
if [[ "$args" = " " ]]; then
    echo="usage: ./syncto.sh 47 128 "
    exit 0
fi
echo "args='$args'"

host47=47.92.151.165
user47=matrix
pass47=TmF0c0V0Y2RQYXJzZXI

host128=10.100.30.128
user128=root
pass128=VWluby5jb21eNzg5KQ
wcmd128="su - matrix"

mqlpath=`go env GOPATH | awk -F ':' '{print $1}'`/bin/matrix/mql
cd ${mqlpath}

while [[ "${args}" != "" ]]; do
    an=`echo $args | awk -F ' ' '{print $1}'`
    ip=`eval "echo $""{host${an}}"`
    user=`eval "echo $""{user${an}}"`
    pass=`eval "echo $""{pass${an}}"`
    wcmd=`eval "echo $""{wcmd${an}}"`
    args=`eval "echo $""{args:${#an}}"`
    echo "$an: $ip"
    if [[ "${ip}" != "" ]]; then
        msh "a=${pass}" c="rsync -avz --exclude=*.count --exclude=*.lock --exclude=*.log --exclude=*.conf . ${user}@${ip}:/opt/matrix/test"
        sleep 2
    fi
done
