Thomas Vachuska | 52e6580 | 2014-12-08 09:26:01 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Remotely pushes bits to a remote node in preparation for install. |
| 4 | # ----------------------------------------------------------------------------- |
Ayaka Koshibe | f17f34a | 2015-09-24 19:31:48 -0700 | [diff] [blame] | 5 | function _usage () { |
| 6 | cat << _EOF_ |
| 7 | usage: |
| 8 | $(basename $0) [node] |
| 9 | |
| 10 | options: |
| 11 | - [node] : the target node to prime for installation |
| 12 | |
| 13 | summary: |
| 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 Lantz | 02ba2d1 | 2016-02-10 23:41:53 -0800 | [diff] [blame^] | 22 | [ $# -gt 1 ] || [ "$1" = "-h" ] && _usage && exit 0 |
| 23 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT isn't set correctly" >&2 && exit 1 |
| 24 | set -e |
| 25 | set -u |
Thomas Vachuska | 52e6580 | 2014-12-08 09:26:01 -0800 | [diff] [blame] | 26 | . $ONOS_ROOT/tools/build/envDefaults |
Bob Lantz | 02ba2d1 | 2016-02-10 23:41:53 -0800 | [diff] [blame^] | 27 | [ ! -f "$ONOS_TAR" ] && echo "$ONOS_TAR does not exist - run onos-package?" >&2 && exit 1 |
Thomas Vachuska | 52e6580 | 2014-12-08 09:26:01 -0800 | [diff] [blame] | 28 | |
| 29 | node=${1:-$OCI} |
| 30 | remote=$ONOS_USER@$node |
| 31 | |
| 32 | locHash=$(cksum $ONOS_TAR | cut -d' ' -f1,2) |
Jonathan Hart | 520f227 | 2015-01-15 16:06:32 -0800 | [diff] [blame] | 33 | remHash=$(ssh $remote cksum $ONOS_TAR 2>/dev/null | cut -d' ' -f1,2) |
Thomas Vachuska | 52e6580 | 2014-12-08 09:26:01 -0800 | [diff] [blame] | 34 | |
Bob Lantz | 02ba2d1 | 2016-02-10 23:41:53 -0800 | [diff] [blame^] | 35 | if [ -n "$locHash" ] && [ "$locHash" = "$remHash" ]; then |
Thomas Vachuska | 52e6580 | 2014-12-08 09:26:01 -0800 | [diff] [blame] | 36 | echo "ONOS bits $ONOS_TAR already up-to-date on $node..." |
| 37 | else |
| 38 | scp -q $ONOS_TAR $remote:/tmp |
| 39 | fi |