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 | |
Jordan Halterman | 00e92da | 2018-05-22 23:05:52 -0700 | [diff] [blame] | 29 | while getopts fnvm: o; do |
| 30 | case "$o" in |
| 31 | f) uninstall=true;; |
| 32 | n) nostart=true;; |
| 33 | esac |
| 34 | done |
| 35 | let OPC=$OPTIND-1 |
| 36 | shift $OPC |
| 37 | |
| 38 | # If the -f was given, attempt uninstall first. |
| 39 | [ -n "$uninstall" ] && atomix-uninstall ${1:-$OCI} |
| 40 | |
| 41 | node=${1:-$OCI} |
| 42 | remote=$ONOS_USER@$node |
| 43 | |
Jordan Halterman | 2e212e9 | 2018-10-30 12:11:36 -0700 | [diff] [blame] | 44 | $(dirname $0)/atomix-push-bits $node |
| 45 | |
Jordan Halterman | 00e92da | 2018-05-22 23:05:52 -0700 | [diff] [blame] | 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 | 6b38425 | 2018-10-26 19:13:25 -0700 | [diff] [blame] | 50 | tar -xvf /tmp/atomix.tar.gz -C $ATOMIX_INSTALL_DIR |
pierventre | b418e11 | 2021-05-04 16:48:36 +0200 | [diff] [blame] | 51 | |
| 52 | if [ ! -z "$ONOS_YOURKIT" ]; then |
| 53 | sudo apt-get install unzip |
| 54 | cd /tmp |
| 55 | wget -N https://www.yourkit.com/download/YourKit-JavaProfiler-${ONOS_YOURKIT}.zip |
| 56 | unzip -o YourKit-JavaProfiler-${ONOS_YOURKIT}.zip |
| 57 | rm YourKit-JavaProfiler-${ONOS_YOURKIT}.zip |
| 58 | mv /tmp/YourKit-JavaProfiler-$(echo $ONOS_YOURKIT | sed 's/\(.*\)-.*/\1/')/bin/linux-x86-64/libyjpagent.so $ATOMIX_INSTALL_DIR/libyjpagent.so |
| 59 | fi |
Jordan Halterman | 00e92da | 2018-05-22 23:05:52 -0700 | [diff] [blame] | 60 | " |
| 61 | |
| 62 | # Configure the ONOS installation |
| 63 | atomix-config $node |
| 64 | |
| 65 | # Upload the shared cluster key if present |
| 66 | [ -f "$ONOS_CLUSTER_KEY_FILE" ] && onos-push-cluster-key $1 |
| 67 | |
| 68 | # Unless -n option was given, attempt to ignite the ONOS service. |
| 69 | [ -z "$nostart" ] && atomix-service $node start || true |