tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 2 | # ----------------------------------------------------------------------------- |
tom | 1a2908c | 2014-09-23 16:37:39 -0700 | [diff] [blame] | 3 | # Remotely stops & uninstalls ONOS on the specified node. |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 4 | # ----------------------------------------------------------------------------- |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 5 | |
Ayaka Koshibe | f17f34a | 2015-09-24 19:31:48 -0700 | [diff] [blame^] | 6 | function _usage () { |
| 7 | cat << _EOF_ |
| 8 | usage: |
| 9 | $(basename $0) [node] |
| 10 | |
| 11 | options: |
| 12 | - [node] : The remote instance to uninstall ONOS from. |
| 13 | |
| 14 | summary: |
| 15 | Remotely stops and uninstalls ONOS 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 | |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 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 | |
Pavlin Radoslavov | 20bc6ae | 2014-12-03 05:35:04 +0000 | [diff] [blame] | 29 | ssh $remote " |
Jonathan Hart | d0a97bc | 2015-07-21 10:31:44 -0700 | [diff] [blame] | 30 | sudo stop onos 1>/dev/null 2>/dev/null |
Brian O'Connor | c045c4a | 2015-09-17 16:09:44 -0700 | [diff] [blame] | 31 | |
| 32 | # Wait for onos to stop up to 5 seconds |
| 33 | for i in \$(seq 1 5); do |
| 34 | [ -z \"\$(ps -ef | grep karaf.jar | grep -v grep)\" ] && break |
| 35 | sleep 1 |
| 36 | done |
| 37 | [ -z \"\$(ps -ef | grep karaf.jar | grep -v grep)\" ] || echo 'ONOS failed to stop.' |
| 38 | |
| 39 | # Remove onos directory and init file |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 40 | sudo rm -fr $ONOS_INSTALL_DIR |
Brian O'Connor | c045c4a | 2015-09-17 16:09:44 -0700 | [diff] [blame] | 41 | [ -f /etc/init/onos.conf ] && sudo rm /etc/init/onos.conf |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 42 | " |