Jordan Halterman | 00e92da | 2018-05-22 23:05:52 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Remotely stops & uninstalls ONOS on the specified node. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | function _usage () { |
| 7 | cat << _EOF_ |
| 8 | usage: |
| 9 | $(basename $0) [node] |
| 10 | |
| 11 | options: |
| 12 | - [node] : The remote instance to uninstall Atomix from. |
| 13 | |
| 14 | summary: |
| 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 | |
| 27 | remote=$ONOS_USER@${1:-$OCI} |
| 28 | |
| 29 | ssh -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 | " |