#!/bin/bash
# SCP a file from this node to the other node
# mReschke 2012-02-21

# Include main cluster.conf
source /etc/nwq/cluster/cluster.conf

if [ "$1" == "" -o "$1" == "--help" ]; then
    echo "scpnode by mReschke 2012-02-21"
    echo "Copy file from this node to the other node"
    echo
    echo "Usage:"
    echo "  scpnode somefile /etc/somedir/"
    echo "  scpnode /full/path/somefile /full/path/"
    echo "  scpnode --help"
else
    if [ "$HOSTNAME" == "$host1" ]; then
        echo "Copying $1 to $host2:$2"
        scp -P $port2 $1 root@$host2:$2
    elif [ "$HOSTNAME" == "$host2" ]; then
        echo "Copying $1 to $host1:$2"
        scp -P $port1 $1 root@$host1:$2
    else
        echo "Error, check hostnames"
        exit 1
    fi
fi
exit 0

