blob: 271b86a15dcc7cfc047fbda9027c222d236a2bb9 [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 "
Jordan Halterman0b3ad5b2018-08-06 12:15:08 -070030 pid=\$(ps -ef | grep AtomixAgent | grep -v grep | cut -c10-15 | tr -d ' ')
Jordan Halterman00e92da2018-05-22 23:05:52 -070031 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"