Jordan Halterman | 00e92da | 2018-05-22 23:05:52 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Remotely pushes bits to a remote node and installs ONOS on it. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | function _usage () { |
| 7 | cat << _EOF_ |
| 8 | usage: |
| 9 | $(basename $0) [-fn] [-m] <settings> [node] |
| 10 | |
| 11 | options: |
| 12 | - [node] : remote node to install ONOS on. |
| 13 | |
| 14 | summary: |
| 15 | Downloads Atomix bits to a remote node and installs Atomix on it. |
| 16 | |
| 17 | The -u should be used on upstart-based systems. |
| 18 | |
| 19 | If [node] is not specified the default target is \$OCI. |
| 20 | |
| 21 | _EOF_ |
| 22 | } |
| 23 | |
| 24 | [ "$1" = "-h" ] && _usage && exit 0 |
| 25 | |
| 26 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 27 | . $ONOS_ROOT/tools/build/envDefaults |
| 28 | |
| 29 | onos-check-bits |
| 30 | |
| 31 | while getopts fnvm: o; do |
| 32 | case "$o" in |
| 33 | f) uninstall=true;; |
| 34 | n) nostart=true;; |
| 35 | esac |
| 36 | done |
| 37 | let OPC=$OPTIND-1 |
| 38 | shift $OPC |
| 39 | |
| 40 | # If the -f was given, attempt uninstall first. |
| 41 | [ -n "$uninstall" ] && atomix-uninstall ${1:-$OCI} |
| 42 | |
| 43 | node=${1:-$OCI} |
| 44 | remote=$ONOS_USER@$node |
| 45 | |
| 46 | ssh -tt $remote " |
Jordan Halterman | 6aca84c | 2018-07-31 13:33:13 -0700 | [diff] [blame] | 47 | [ -f $ATOMIX_INSTALL_DIR/bin/atomix-agent ] && echo \"Atomix is already installed\" && exit 1 |
Jordan Halterman | 00e92da | 2018-05-22 23:05:52 -0700 | [diff] [blame] | 48 | |
| 49 | sudo mkdir -p $ATOMIX_INSTALL_DIR && sudo chown ${ONOS_USER}:${ONOS_GROUP} $ATOMIX_INSTALL_DIR |
Jordan Halterman | e075338 | 2018-08-20 15:32:11 -0700 | [diff] [blame] | 50 | sudo wget -O $ATOMIX_INSTALL_DIR/atomix-dist.tar.gz https://oss.sonatype.org/content/repositories/releases/io/atomix/atomix-dist/3.0.0/atomix-dist-3.0.0.tar.gz |
Jordan Halterman | 6aca84c | 2018-07-31 13:33:13 -0700 | [diff] [blame] | 51 | tar -xvf $ATOMIX_INSTALL_DIR/atomix-dist.tar.gz -C $ATOMIX_INSTALL_DIR |
Jordan Halterman | 00e92da | 2018-05-22 23:05:52 -0700 | [diff] [blame] | 52 | " |
| 53 | |
| 54 | # Configure the ONOS installation |
| 55 | atomix-config $node |
| 56 | |
| 57 | # Upload the shared cluster key if present |
| 58 | [ -f "$ONOS_CLUSTER_KEY_FILE" ] && onos-push-cluster-key $1 |
| 59 | |
| 60 | # Unless -n option was given, attempt to ignite the ONOS service. |
| 61 | [ -z "$nostart" ] && atomix-service $node start || true |