blob: dff64e0da2959fd2af71421d21b254bd2c1089ba [file] [log] [blame]
Thomas Vachuska52e65802014-12-08 09:26:01 -08001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Remotely pushes bits to a remote node in preparation for install.
4# -----------------------------------------------------------------------------
Ayaka Koshibef17f34a2015-09-24 19:31:48 -07005function _usage () {
6cat << _EOF_
7usage:
8 $(basename $0) [node]
9
10options:
11- [node] : the target node to prime for installation
12
13summary:
14 Remotely pushes bits to a remote node in preparation for install.
15
16 $(basename $0) is invoked as part of 'onos-install', and shouldn't be
17 directly invoked for the most part.
18
19_EOF_
20}
21
Bob Lantz02ba2d12016-02-10 23:41:53 -080022[ $# -gt 1 ] || [ "$1" = "-h" ] && _usage && exit 0
23[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT isn't set correctly" >&2 && exit 1
24set -e
25set -u
Thomas Vachuska52e65802014-12-08 09:26:01 -080026. $ONOS_ROOT/tools/build/envDefaults
Bob Lantz02ba2d12016-02-10 23:41:53 -080027[ ! -f "$ONOS_TAR" ] && echo "$ONOS_TAR does not exist - run onos-package?" >&2 && exit 1
Thomas Vachuska52e65802014-12-08 09:26:01 -080028
29node=${1:-$OCI}
30remote=$ONOS_USER@$node
31
32locHash=$(cksum $ONOS_TAR | cut -d' ' -f1,2)
Jonathan Hart520f2272015-01-15 16:06:32 -080033remHash=$(ssh $remote cksum $ONOS_TAR 2>/dev/null | cut -d' ' -f1,2)
Thomas Vachuska52e65802014-12-08 09:26:01 -080034
Bob Lantz02ba2d12016-02-10 23:41:53 -080035if [ -n "$locHash" ] && [ "$locHash" = "$remHash" ]; then
Thomas Vachuska52e65802014-12-08 09:26:01 -080036 echo "ONOS bits $ONOS_TAR already up-to-date on $node..."
37else
38 scp -q $ONOS_TAR $remote:/tmp
39fi