blob: c1ca86d9b187eec8247b95703c197bf47cc2afaa [file] [log] [blame]
Jordan Halterman00e92da2018-05-22 23:05:52 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Remotely stops & uninstalls ONOS on the specified node.
4# -----------------------------------------------------------------------------
5
6function _usage () {
7cat << _EOF_
8usage:
9 $(basename $0) [node]
10
11options:
12- [node] : The remote instance to uninstall Atomix from.
13
14summary:
15 Remotely stops and uninstalls Atomix on the specified node.
16
17 If [node] isn't specified, \$OCI becomes the target.
18
19_EOF_
20}
21
22[ "$1" = "-h" ] && _usage && exit 0
23
24[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
25. $ONOS_ROOT/tools/build/envDefaults
26
27remote=$ONOS_USER@${1:-$OCI}
28
29ssh -tt $remote "
30 pid=\$(ps -ef | grep atomix-agent.jar | grep -v grep | cut -c10-15 | tr -d ' ')
31 if [ -n \"\$pid\" ]; then
32 echo \"Killing Atomix process \$pid on \$(hostname)...\"
33 kill -9 \$pid
34 else
35 echo \"Atomix process is not running...\"
36 fi
37
38 # Remove Atomix directory
39 [ -d $ATOMIX_INSTALL_DIR ] && sudo rm -fr $ATOMIX_INSTALL_DIR
40
41 exit \${status:-0};
42"