blob: b059e12d0f18ec8e811006aade951122d9d13814 [file] [log] [blame]
Jordan Halterman00e92da2018-05-22 23:05:52 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Remotely pushes bits to a remote node and installs ONOS on it.
4# -----------------------------------------------------------------------------
5
6function _usage () {
7cat << _EOF_
8usage:
9 $(basename $0) [-fn] [-m] <settings> [node]
10
11options:
12- [node] : remote node to install ONOS on.
13
14summary:
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
Jordan Halterman00e92da2018-05-22 23:05:52 -070029while getopts fnvm: o; do
30 case "$o" in
31 f) uninstall=true;;
32 n) nostart=true;;
33 esac
34done
35let OPC=$OPTIND-1
36shift $OPC
37
38# If the -f was given, attempt uninstall first.
39[ -n "$uninstall" ] && atomix-uninstall ${1:-$OCI}
40
41node=${1:-$OCI}
42remote=$ONOS_USER@$node
43
Jordan Halterman8c022172018-10-30 12:11:36 -070044$(dirname $0)/atomix-push-bits $node
45
Jordan Halterman00e92da2018-05-22 23:05:52 -070046ssh -tt $remote "
Jordan Halterman6aca84c2018-07-31 13:33:13 -070047 [ -f $ATOMIX_INSTALL_DIR/bin/atomix-agent ] && echo \"Atomix is already installed\" && exit 1
Jordan Halterman00e92da2018-05-22 23:05:52 -070048
49 sudo mkdir -p $ATOMIX_INSTALL_DIR && sudo chown ${ONOS_USER}:${ONOS_GROUP} $ATOMIX_INSTALL_DIR
Jordan Halterman3f0db0a2018-10-26 19:13:25 -070050 tar -xvf /tmp/atomix.tar.gz -C $ATOMIX_INSTALL_DIR
Jordan Halterman00e92da2018-05-22 23:05:52 -070051"
52
53# Configure the ONOS installation
54atomix-config $node
55
56# Upload the shared cluster key if present
57[ -f "$ONOS_CLUSTER_KEY_FILE" ] && onos-push-cluster-key $1
58
59# Unless -n option was given, attempt to ignite the ONOS service.
60[ -z "$nostart" ] && atomix-service $node start || true