Jordan Halterman | 3f0db0a | 2018-10-26 19:13:25 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Remotely pushes bits to a remote node in preparation for install. |
| 4 | # ----------------------------------------------------------------------------- |
| 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 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 | |
| 25 | set -e |
| 26 | |
| 27 | . $ONOS_ROOT/tools/build/envDefaults |
| 28 | |
| 29 | ATOMIX_VERSION=${ATOMIX_VERSION:-3.0.7} |
| 30 | ATOMIX_MAVEN=~/.m2/repository/io/atomix/atomix-dist/$ATOMIX_VERSION/atomix-dist-$ATOMIX_VERSION.tar.gz |
| 31 | ATOMIX_LOCAL=/tmp/atomix-$ATOMIX_VERSION.tar.gz |
| 32 | ATOMIX_REMOTE=https://oss.sonatype.org/content/repositories/releases/io/atomix/atomix-dist/$ATOMIX_VERSION/atomix-dist-$ATOMIX_VERSION.tar.gz |
| 33 | |
| 34 | node=${1:-$OCI} |
| 35 | remote=$ONOS_USER@$node |
| 36 | remote_with_bracket=$ONOS_USER@[$node] |
| 37 | SSH_OPTIONS=" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ |
| 38 | -o ControlMaster=auto -o ControlPath=~/.ssh/mux-%r@%h:%p \ |
| 39 | -o ControlPersist=300 " |
| 40 | |
| 41 | if [ ! -z "$ATOMIX_ROOT" ]; then |
| 42 | echo "Pushing to $node from $ATOMIX_ROOT" |
| 43 | ATOMIX_TAR=$ATOMIX_ROOT/dist/target/atomix.tar.gz |
Jordan Halterman | 8c02217 | 2018-10-30 12:11:36 -0700 | [diff] [blame] | 44 | elif [ -e "$ATOMIX_MAVEN" ]; then |
Jordan Halterman | 3f0db0a | 2018-10-26 19:13:25 -0700 | [diff] [blame] | 45 | echo "Pushing to $node from $ATOMIX_MAVEN" |
| 46 | ATOMIX_TAR=$ATOMIX_MAVEN |
| 47 | else |
| 48 | echo "Pushing to $node from $ATOMIX_LOCAL" |
Jordan Halterman | 8c02217 | 2018-10-30 12:11:36 -0700 | [diff] [blame] | 49 | if [ ! -f "$ATOMIX_LOCAL" ]; then |
Jordan Halterman | 111160c | 2018-11-05 12:15:11 -0800 | [diff] [blame^] | 50 | curl -o $ATOMIX_LOCAL $ATOMIX_REMOTE |
Jordan Halterman | 8c02217 | 2018-10-30 12:11:36 -0700 | [diff] [blame] | 51 | fi |
Jordan Halterman | 3f0db0a | 2018-10-26 19:13:25 -0700 | [diff] [blame] | 52 | ATOMIX_TAR=$ATOMIX_LOCAL |
| 53 | fi |
| 54 | |
| 55 | echo "Using scp" |
| 56 | |
| 57 | locHash=$(cksum $ATOMIX_TAR | cut -d' ' -f1,2) |
| 58 | remHash=$(ssh $remote cksum /tmp/atomix.tar.gz 2>/dev/null | cut -d' ' -f1,2) |
| 59 | |
| 60 | if [ -n "$locHash" ] && [ "$locHash" = "$remHash" ]; then |
| 61 | echo "Atomix bits /tmp/atomix.tar.gz already up-to-date on $node..." |
| 62 | else |
Jordan Halterman | 67a65a0 | 2018-10-30 11:16:40 -0700 | [diff] [blame] | 63 | ssh $remote rm -f /tmp/atomix.tar.gz |
Jordan Halterman | 3f0db0a | 2018-10-26 19:13:25 -0700 | [diff] [blame] | 64 | scp -q $ATOMIX_TAR $remote_with_bracket:/tmp/atomix.tar.gz |
| 65 | fi |