blob: f82328120ada61898f7349f997c53a0016ef4bd9 [file] [log] [blame]
Jordan Halterman6b384252018-10-26 19:13:25 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Remotely pushes bits to a remote node in preparation for install.
4# -----------------------------------------------------------------------------
5function _usage () {
6cat << _EOF_
7usage:
8 $(basename $0) [node]
9
10options:
11- [node] : the target node to prime for installation
12
13summary:
14 Remotely pushes Atomix bits to a remote node in preparation for install.
15
16 $(basename $0) is invoked as part of 'atomix-install', and shouldn't be
17 directly invoked for the most part.
18
19_EOF_
20}
21
22[ $# -gt 1 ] || [ "$1" = "-h" ] && _usage && exit 0
23[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT isn't set correctly" >&2 && exit 1
24
25set -e
26
27. $ONOS_ROOT/tools/build/envDefaults
28
Jordan Halterman8b17e0e2018-12-18 13:57:36 -080029ATOMIX_VERSION=${ATOMIX_VERSION:-3.1.0-rc2}
Jordan Halterman6b384252018-10-26 19:13:25 -070030ATOMIX_MAVEN=~/.m2/repository/io/atomix/atomix-dist/$ATOMIX_VERSION/atomix-dist-$ATOMIX_VERSION.tar.gz
31ATOMIX_LOCAL=/tmp/atomix-$ATOMIX_VERSION.tar.gz
32ATOMIX_REMOTE=https://oss.sonatype.org/content/repositories/releases/io/atomix/atomix-dist/$ATOMIX_VERSION/atomix-dist-$ATOMIX_VERSION.tar.gz
33
34node=${1:-$OCI}
35remote=$ONOS_USER@$node
36remote_with_bracket=$ONOS_USER@[$node]
37SSH_OPTIONS=" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
38 -o ControlMaster=auto -o ControlPath=~/.ssh/mux-%r@%h:%p \
39 -o ControlPersist=300 "
40
41if [ ! -z "$ATOMIX_ROOT" ]; then
42 echo "Pushing to $node from $ATOMIX_ROOT"
43 ATOMIX_TAR=$ATOMIX_ROOT/dist/target/atomix.tar.gz
Jordan Halterman2e212e92018-10-30 12:11:36 -070044elif [ -e "$ATOMIX_MAVEN" ]; then
Jordan Halterman6b384252018-10-26 19:13:25 -070045 echo "Pushing to $node from $ATOMIX_MAVEN"
46 ATOMIX_TAR=$ATOMIX_MAVEN
47else
48 echo "Pushing to $node from $ATOMIX_LOCAL"
Jordan Halterman2e212e92018-10-30 12:11:36 -070049 if [ ! -f "$ATOMIX_LOCAL" ]; then
Jordan Haltermandf5016d2018-11-05 12:15:11 -080050 curl -o $ATOMIX_LOCAL $ATOMIX_REMOTE
Jordan Halterman2e212e92018-10-30 12:11:36 -070051 fi
Jordan Halterman6b384252018-10-26 19:13:25 -070052 ATOMIX_TAR=$ATOMIX_LOCAL
53fi
54
55echo "Using scp"
56
57locHash=$(cksum $ATOMIX_TAR | cut -d' ' -f1,2)
58remHash=$(ssh $remote cksum /tmp/atomix.tar.gz 2>/dev/null | cut -d' ' -f1,2)
59
60if [ -n "$locHash" ] && [ "$locHash" = "$remHash" ]; then
61 echo "Atomix bits /tmp/atomix.tar.gz already up-to-date on $node..."
62else
Jordan Halterman77811ba2018-10-30 11:16:40 -070063 ssh $remote rm -f /tmp/atomix.tar.gz
Jordan Halterman6b384252018-10-26 19:13:25 -070064 scp -q $ATOMIX_TAR $remote_with_bracket:/tmp/atomix.tar.gz
65fi